function [msg,nfft,Fs,window,noverlap,p,dflag] = mypsdchk(P,x,y)
%输入参数说明:数组P可为0-7个数的数组参数;y是可选项,若给出,必须与x的长度相同
% x必须是一个数值向量
% 输出参数说明: msg-错误信息,没有错误为[];nfft - fft变换的指定长度
% Fs-抽样频率;window-窗函数数组;noverlap - overlap of sections, in samples
% p-confidence interval, [] if none desired;dflag - detrending flag, 'linear' 'mean' or 'none'
msg = []; %信息提示数组初始化
if length(P) == 0 %输入数组为0的情况下,对输出参数赋值
% psd(x)
nfft = min(length(x),256);
window = hanning(nfft);
noverlap = 0;
Fs = 2;
p = [];
dflag = 'none';
elseif length(P) == 1 %输入数组为1的情况下,对输出参数赋值
if isempty(P{1}), dflag = 'none'; nfft = min(length(x),256);
elseif isstr(P{1}), dflag = P{1}; nfft = min(length(x),256);
else dflag = 'none'; nfft = P{1}; end
Fs = 2;
window = hanning(nfft);
noverlap = 0;
p = [];
elseif length(P) == 2 %输入数组为2的情况下,对输出参数赋值
if isempty(P{1}), nfft = min(length(x),256); else nfft=P{1}; end
if isempty(P{2}), dflag = 'none'; Fs = 2;
elseif isstr(P{2}), dflag = P{2}; Fs = 2;
else dflag = 'none'; Fs = P{2}; end
window = hanning(nfft);
noverlap = 0;
p = [];
elseif length(P) == 3 %输入数组为3的情况下,对输出参数赋值
if isempty(P{1}), nfft = min(length(x),256); else nfft=P{1}; end
if isempty(P{2}), Fs = 2; else Fs = P{2}; end
if isstr(P{3})
dflag = P{3};
window = hanning(nfft);
else
dflag = 'none';
window = P{3};
if length(window) == 1, window = hanning(window); end
if isempty(window), window = hanning(nfft); end
end
noverlap = 0;
p = [];
elseif length(P) == 4 %输入数组为4的情况下,对输出参数赋值
if isempty(P{1}), nfft = min(length(x),256); else nfft=P{1}; end
if isempty(P{2}), Fs = 2; else Fs = P{2}; end
window = P{3};
if length(window) == 1, window = hanning(window); end
if isempty(window), window = hanning(nfft); end
if isstr(P{4})
dflag = P{4};
noverlap = 0;
else
dflag = 'none';
if isempty(P{4}), noverlap = 0; else noverlap = P{4}; end
end
p = [];
elseif length(P) == 5 %输入数组为5的情况下,对输出参数赋值
if isempty(P{1}), nfft = min(length(x),256); else nfft=P{1}; end
if isempty(P{2}), Fs = 2; else Fs = P{2}; end
window = P{3};
if length(window) == 1, window = hanning(window); end
if isempty(window), window = hanning(nfft); end
if isempty(P{4}), noverlap = 0; else noverlap = P{4}; end
if isstr(P{5})
dflag = P{5};
p = [];
else
dflag = 'none';
if isempty(P{5}), p = .95; else p = P{5}; end
end
elseif length(P) == 6 %输入数组为6的情况下,对输出参数赋值
if isempty(P{1}), nfft = min(length(x),256); else nfft=P{1}; end
if isempty(P{2}), Fs = 2; else Fs = P{2}; end
window = P{3};
if length(window) == 1, window = hanning(window); end
if isempty(window), window = hanning(nfft); end
if isempty(P{4}), noverlap = 0; else noverlap = P{4}; end
if isempty(P{5}), p = .95; else p = P{5}; end
if isstr(P{6})
dflag = P{6};
else
msg = 'DFLAG parameter must be a string.'; return
end
end
% 进行错误检测
if (nfft<length(window)),
msg = 'Requires window''s length to be no greater than the FFT length.';
end
if (noverlap >= length(window)),
msg = 'Requires NOVERLAP to be strictly less than the window length.';
end
if (nfft ~= abs(round(nfft)))|(noverlap ~= abs(round(noverlap))),
msg = 'Requires positive integer values for NFFT and NOVERLAP.';
end
if ~isempty(p),
if (prod(size(p))>1)|(p(1,1)>1)|(p(1,1)<0),
msg = 'Requires confidence parameter to be a scalar between 0 and 1.';
end
end
if min(size(x))~=1 | ~isnumeric(x) | length(size(x))>2
msg = 'Requires vector (either row or column) input.';
end
if (nargin>2) & ( (min(size(y))~=1) | ~isnumeric(y) | length(size(y))>2 )
msg = 'Requires vector (either row or column) input.';
end
if (nargin>2) & (length(x)~=length(y))
msg = 'Requires X and Y be the same length.';
end
dflag = lower(dflag);
if strncmp(dflag,'none',1)
dflag = 'none';
elseif strncmp(dflag,'linear',1)
dflag = 'linear';
elseif strncmp(dflag,'mean',1)
dflag = 'mean';
else
msg = 'DFLAG must be ''linear'', ''mean'', or ''none''.';
end
xitongbianshi.rar_噪声系统辨识_系统辨识
版权申诉
128 浏览量
2022-09-24
15:35:29
上传
评论
收藏 3KB RAR 举报
局外狗
- 粉丝: 64
- 资源: 1万+
最新资源
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
- 基于MIC+NE555光敏电阻的声光控电路Multisim仿真原理图
- 基于JSP毕业设计-基于WEB操作系统课程教学网站的设计与实现(源代码+论文).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈