声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1954|回复: 4

[综合讨论] [求助]MATLAB求助:psdchk函数的相关帮助

[复制链接]
发表于 2006-6-18 10:28 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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

回复
分享到:

使用道具 举报

发表于 2006-6-18 22:35 | 显示全部楼层

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

<P>function [msg,nfft,Fs,window,noverlap,p,dflag] = psdchk(P,x,y)<BR>%PSDCHK Helper function for PSD, CSD, COHERE, and TFE.<BR>%   [msg,nfft,Fs,window,noverlap,p,dflag]=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>
发表于 2006-6-18 22:39 | 显示全部楼层

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

内部函数是看不了的,可能是技术保密吧
 楼主| 发表于 2006-6-18 23:21 | 显示全部楼层
我想应该就是了,只是老师怎么得到这些信息的?
发表于 2006-6-23 20:40 | 显示全部楼层

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

<DIV class=quote><B>以下是引用<I>pheigenbau</I>在2006-6-18 23:21:06的发言:</B><BR>我想应该就是了,只是老师怎么得到这些信息的?</DIV>
<P>这些东西有些可以在网上搜到</P>
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-20 04:21 , Processed in 0.064998 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表