|
我在做频谱校正时加hanning窗时程序出错,恳请高人指点一下
先谢过了!
t=0:0.00001:0.02;
leng=length(t);
for m=1:leng
if t(m)<0.00167
v(m)=0;
elseif ((t(m)>=0.00167)&(t(m)<0.01))
v(m)=sin(2*pi*50*t(m));
elseif ((t(m)>=0.01)&(t(m)<0.01167))
v(m)=0;
elseif t(m)>=0.01167
v(m)=sin(2*pi*50*t(m));
end
end
plot(t,v);grid;
N=2000;
w=hanning(2000);v=v.*w';
y=fft(v,N);
mag=abs(y)*2/N;
f=(0:length(y)-1)'*100000/length(y);
figure;
plot(f(1:N/2),mag(1:N/2));
axis([0,1000,0,1]);
xlabel('频率(Hz)');ylabel('幅值');
grid;
出错信息为:??? Error using ==> times
Matrix dimensions must agree.
Error in ==> hanshu at 16
w=hanning(2000);v=v.*w'; |
|