pheigenbau 发表于 2006-6-18 10:28

[求助]MATLAB求助:psdchk函数的相关帮助

在看一些函数的代码时,经常看见一些"内部"命令,比如函数psd(),里面就有一个函数是psdchk(),可是却找不到这个函数的相关帮助,不知这是怎么回事.类似的例子还不少,一般情况是母函数func(),内部有一子函数为funcchk(),当作是参数检测,求各位大虾指点迷津
[此贴子已经被ericlin于2006-6-18 14:37:46编辑过]

happy 发表于 2006-6-18 22:35

回复:(pheigenbau)[求助]MATLAB求助:psdchk函数的相...

<P>function = psdchk(P,x,y)<BR>%PSDCHK Helper function for PSD, CSD, COHERE, and TFE.<BR>%   =PSDCHK(P,x,y) takes the cell <BR>%   array P and uses each element as an input argument.Assumes P has <BR>%   between 0 and 7 elements which are the arguments to psd, csd, cohere<BR>%   or tfe after the x (psd) or x and y (csd, cohere, tfe) arguments.<BR>%   y is optional; if given, it is checked to match the size of x.<BR>%   x must be a numeric vector.<BR>%   Outputs:<BR>%   msg - error message, [] if no error<BR>%   nfft - fft length<BR>%   Fs - sampling frequency<BR>%   window - window vector<BR>%   noverlap - overlap of sections, in samples<BR>%   p - confidence interval, [] if none desired<BR>%   dflag - detrending flag, 'linear' 'mean' or 'none'</P>
<P>%   Author(s): T. Krauss, 10-28-93</P>
<P>msg = [];</P>
<P>if length(P) == 0 <BR>% psd(x)<BR>    nfft = min(length(x),256);<BR>    window = hanning(nfft);<BR>    noverlap = 0;<BR>    Fs = 2;<BR>    p = [];<BR>    dflag = 'none';<BR>elseif length(P) == 1<BR>% psd(x,nfft)<BR>% psd(x,dflag)<BR>    if isempty(P{1}),   dflag = 'none'; nfft = min(length(x),256); <BR>    elseif isstr(P{1}), dflag = P{1};       nfft = min(length(x),256); <BR>    else            dflag = 'none'; nfft = P{1};   end<BR>    Fs = 2;<BR>    window = hanning(nfft);<BR>    noverlap = 0;<BR>    p = [];<BR>elseif length(P) == 2<BR>% psd(x,nfft,Fs)<BR>% psd(x,nfft,dflag)<BR>    if isempty(P{1}), nfft = min(length(x),256); else nfft=P{1};   end<BR>    if isempty(P{2}),   dflag = 'none'; Fs = 2;<BR>    elseif isstr(P{2}), dflag = P{2};       Fs = 2;<BR>    else            dflag = 'none'; Fs = P{2}; end<BR>    window = hanning(nfft);<BR>    noverlap = 0;<BR>    p = [];<BR>elseif length(P) == 3<BR>% psd(x,nfft,Fs,window)<BR>% psd(x,nfft,Fs,dflag)<BR>    if isempty(P{1}), nfft = min(length(x),256); else nfft=P{1};   end<BR>    if isempty(P{2}), Fs = 2;   else    Fs = P{2}; end<BR>    if isstr(P{3})<BR>      dflag = P{3};<BR>      window = hanning(nfft);<BR>    else<BR>      dflag = 'none';<BR>      window = P{3};<BR>      if length(window) == 1, window = hanning(window); end<BR>      if isempty(window), window = hanning(nfft); end<BR>    end<BR>    noverlap = 0;<BR>    p = [];<BR>elseif length(P) == 4<BR>% psd(x,nfft,Fs,window,noverlap)<BR>% psd(x,nfft,Fs,window,dflag)<BR>    if isempty(P{1}), nfft = min(length(x),256); else nfft=P{1};   end<BR>    if isempty(P{2}), Fs = 2;   else    Fs = P{2}; end<BR>    window = P{3};<BR>    if length(window) == 1, window = hanning(window); end<BR>    if isempty(window), window = hanning(nfft); end<BR>    if isstr(P{4})<BR>      dflag = P{4};<BR>      noverlap = 0;<BR>    else<BR>      dflag = 'none';<BR>      if isempty(P{4}), noverlap = 0; else noverlap = P{4}; end<BR>    end<BR>    p = [];<BR>elseif length(P) == 5<BR>% psd(x,nfft,Fs,window,noverlap,p)<BR>% psd(x,nfft,Fs,window,noverlap,dflag)<BR>    if isempty(P{1}), nfft = min(length(x),256); else nfft=P{1};   end<BR>    if isempty(P{2}), Fs = 2;   else    Fs = P{2}; end<BR>    window = P{3};<BR>    if length(window) == 1, window = hanning(window); end<BR>    if isempty(window), window = hanning(nfft); end<BR>    if isempty(P{4}), noverlap = 0; else noverlap = P{4}; end<BR>    if isstr(P{5})<BR>      dflag = P{5};<BR>      p = [];<BR>    else<BR>      dflag = 'none';<BR>      if isempty(P{5}), p = .95;    else    p = P{5}; end<BR>    end<BR>elseif length(P) == 6<BR>% psd(x,nfft,Fs,window,noverlap,p,dflag)<BR>    if isempty(P{1}), nfft = min(length(x),256); else nfft=P{1};   end<BR>    if isempty(P{2}), Fs = 2;   else    Fs = P{2}; end<BR>    window = P{3};<BR>    if length(window) == 1, window = hanning(window); end<BR>    if isempty(window), window = hanning(nfft); end<BR>    if isempty(P{4}), noverlap = 0; else noverlap = P{4}; end<BR>    if isempty(P{5}), p = .95;    else    p = P{5}; end<BR>    if isstr(P{6})<BR>      dflag = P{6};<BR>    else<BR>      msg = 'DFLAG parameter must be a string.'; return<BR>    end<BR>end</P>
<P>% NOW do error checking<BR>if (nfft&lt;length(window)), <BR>    msg = 'Requires window''s length to be no greater than the FFT length.';<BR>end<BR>if (noverlap &gt;= length(window)),<BR>    msg = 'Requires NOVERLAP to be strictly less than the window length.';<BR>end<BR>if (nfft ~= abs(round(nfft)))|(noverlap ~= abs(round(noverlap))),<BR>    msg = 'Requires positive integer values for NFFT and NOVERLAP.';<BR>end<BR>if ~isempty(p),<BR>    if (prod(size(p))&gt;1)|(p(1,1)&gt;1)|(p(1,1)&lt;0),<BR>      msg = 'Requires confidence parameter to be a scalar between 0 and 1.';<BR>    end<BR>end<BR>if min(size(x))~=1 | ~isnumeric(x) | length(size(x))&gt;2<BR>    msg = 'Requires vector (either row or column) input.';<BR>end<BR>if (nargin&gt;2) &amp; ( (min(size(y))~=1) | ~isnumeric(y) | length(size(y))&gt;2 )<BR>    msg = 'Requires vector (either row or column) input.';<BR>end<BR>if (nargin&gt;2) &amp; (length(x)~=length(y))<BR>    msg = 'Requires X and Y be the same length.';<BR>end</P>
<P>dflag = lower(dflag);<BR>if strncmp(dflag,'none',1)<BR>      dflag = 'none';<BR>elseif strncmp(dflag,'linear',1)<BR>      dflag = 'linear';<BR>elseif strncmp(dflag,'mean',1)<BR>      dflag = 'mean';<BR>else<BR>    msg = 'DFLAG must be ''linear'', ''mean'', or ''none''.';<BR>end<BR><BR>是不是这个?</P>

happy 发表于 2006-6-18 22:39

回复:(pheigenbau)[求助]MATLAB求助:psdchk函数的相...

内部函数是看不了的,可能是技术保密吧

pheigenbau 发表于 2006-6-18 23:21

我想应该就是了,只是老师怎么得到这些信息的?

happy 发表于 2006-6-23 20:40

回复:(pheigenbau)我想应该就是了,只是老师怎么得到...

<DIV class=quote><B>以下是引用<I>pheigenbau</I>在2006-6-18 23:21:06的发言:</B><BR>我想应该就是了,只是老师怎么得到这些信息的?</DIV>
<P>这些东西有些可以在网上搜到</P>
页: [1]
查看完整版本: [求助]MATLAB求助:psdchk函数的相关帮助