看看m文件怎么回事!!
clearclc
close all hidden
format long
%%%%%%%%%%%%%%%%%%%%%
fni=input('随即信号谱分析-输入数据文件名:','s');
fid=fopen(fni,'r');
fun=fscanf (fid,'%d',1);
sf=fscanf (fid,'%f',1);
nfft=fscanf (fid,'%d',1);
win=fscanf (fid,'%d',1);
fno=fscanf (fid,'%s',1);
a=fscanf (fid,'%f',);
status=fclose (fid);
x=a (1,:);
y=a (2,:)-a (1,:);
f=0: sf/nfft:sf/2-sf/nfft;
switch win
case 1
w=boxcar(nfft);
case 2
w=hanning(nfft);
case 3
w=hamming(nfft);
case 4
w=blackman (nfft);
case 5
w=triang(nfft);
otherwise
w=boxcar(nfft);
end
switch fun
case 1
z=psd(x,y,nfft,sf,w,nfft/2);
case 2
z=csd(x,y,nfft,sf,w,nfft/2);
case 3
z=tfe(x,y,nfft,sf,w,nfft/2);
case 4
z=cohere(x,y,nfft,sf,w,nfft/2);
otherwise
;
end
nn=1:nfft/4;
subplot(2,1,1);
plot (f(nn),abs(z(nn)));
xlabel('频率(Hz)');
ylabel('幅值');
grid on;
if fun>1&fun<4
subplot(2,1,2);
plot (f(nn),abs(z(nn)));
xlabel('频率(Hz)');
ylabel('相位');
grid on;
end
fid=fopen(fno,'w');
if fun>1&fun<4
for k=1:nfft/2
fprintf(fid,'%f%f\n',f(k),abs(z(k)));
end
else
for k=1;nfft/2
fprintf(fid,'%f%f%f\n',f(k),real(z(k)),imag(z(k)));
end
status=fclose(fid);
end 0 0.0214
1 -0.0079
2 0.0262
3 0.0189
4 0.0433
5 0.0165
6 0.0067
7 0.0360
8 0.0067
9 0.0287
10 0.0214
11 0.0116
12 0.0409
13 0.0140
14 0.0140
15 0.0214
16 0.0287
17 0.0214
18 -0.0031
19 0.0238
20 0.0214
21 0.0311
22 0.0165
23 0.0043
24 0.0531
25 0.0214
26 0.0238
27 0.0238
28 0.0067
29 0.0189
30 0.0287 这是数据的一部分 大家给点意见刚开始学习 但是时间不允许了 囫囵吞枣 ??? Undefined function or variable 'psdchk'.
Error in ==> C:\MATLAB6.5\work\psd.m
On line 67==> =psdchk(varargin(2:end),x);
Error in ==> C:\MATLAB6.5\work\sjxh1.m
On line 34==> z=psd(x,y,nfft,sf,w,nfft/2); 原帖由 sql2006 于 2007-1-27 15:42 发表
??? Undefined function or variable 'psdchk'.
Error in ==> C:\MATLAB6.5\work\psd.m
On line 67==> =psdchk(varargin(2:end),x);
Error in ==> C:\MATLAB6.5\work\sjxh1.m
On line 34= ...
把psd(包括m文件名和函数名)改为其他,例如mypsd 已经把psd移动到其它文件夹了
??? Error using ==> psd
Requires confidence parameter to be a scalar between 0 and 1.
Error in ==> C:\MATLAB6.5\work\sjxh.m
On line 34==> z=psd(x,y,nfft,sf,w,nfft/2);
好像是缺少置信度?指点一下!! 原帖由 sql2006 于 2007-1-27 16:19 发表
已经把psd移动到其它文件夹了
??? Error using ==> psd
Requires confidence parameter to be a scalar between 0 and 1.
Error in ==> C:\MATLAB6.5\work\sjxh.m
On line 34==> z=ps ...
自己 help psd 看看吧 如果我想在上述m文件中添加一些东西
运行后直接显示出最大幅值对应频率
应该如何做
怎么编写 case是不是缺少break 原帖由 sql2006 于 2007-1-27 15:42 发表
??? Undefined function or variable 'psdchk'.
Error in ==> C:\MATLAB6.5\work\psd.m
On line 67==> =psdchk(varargin(2:end),x);
Error in ==> C:\MATLAB6.5\work\sjxh1.m
On line 34= ...
http://forum.vibunion.com/thread-17418-1-1.html
页:
[1]