0
让我们考虑下面的代码使用while循环在MATLAB
clear all;
B=xlsread('data_generations1','A1','g8:g301');
% n=input('enter the number from 1 to 16 for windows in periodogram :');
fs=input('enter sampling frequency fs :');
while 1
n=input('enter the number from 1 to 16 for windows in periodogram :');
switch n
case 1
disp('this is hann window ');
[pxx,f]=periodogram(B,hann(length(B)),length(B),fs);
subplot(4,4,1);
plot(f,pxx);
hold on
case 2
disp('this is hamming window ');
[pxx,f]=periodogram(B,hamming(length(B)),length(B),fs);
subplot(4,4,2);
plot(f,pxx);
hold on
case 3
disp('this is kaiser window ');
[pxx,f]=periodogram(B,kaiser(length(B),2.5),length(B),fs);
subplot(4,4,3);
plot(f,pxx);
hold on
case 4
disp('this is barlett window ');
[pxx,f]=periodogram(B,bartlett(length(B)),length(B),fs);
subplot(4,4,4);
plot(f,pxx);
hold on
case 5
disp('this is bohmanwin window ');
[pxx,f]=periodogram(B,bohmanwin(length(B)),length(B),fs);
subplot(4,4,5);
plot(f,pxx);
hold on
case 6
[pxx,f]=periodogram(B,rectwin(length(B)),length(B),fs);
subplot(4,4,6);
plot(f,pxx);
hold on
case 7
[pxx,f]=periodogram(B,triang(length(B)),length(B),fs);
subplot(4,4,7);
plot(f,pxx);
hold on
case 8
[pxx,f]=periodogram(B,gausswin(length(B),2.5),length(B),fs);
subplot(4,4,8);
plot(f,pxx);
hold on
case 9
[pxx,f]=periodogram(B,flattopwin(length(B),'periodic'),length(B),fs);
subplot(4,4,9);
plot(f,pxx);
hold on
case 10
[pxx,f]=periodogram(B,gausswin(length(B),2.5),length(B),fs);
subplot(4,4,10);
plot(f,pxx);
hold on
case 11
[pxx,f]=periodogram(B,tukeywin(length(B),0.5),length(B),fs);
subplot(4,4,11);
plot(f,pxx);
hold on
case 12
[pxx,f]=periodogram(B,taylorwin(length(B)),length(B),fs);
subplot(4,4,12);
plot(f,pxx);
hold on
case 13
[pxx,f]=periodogram(B,barthannwin(length(B)),length(B),fs);
subplot(4,4,13);
plot(f,pxx);
hold on
case 14
[pxx,f]=periodogram(B,parzenwin(length(B)),length(B),fs);
subplot(4,4,14);
plot(f,pxx);
hold on
case 15
[pxx,f]=periodogram(B,nuttalwin(length(B),'periodic'),length(B),fs);
subplot(4,4,15);
plot(f,pxx);
hold on
case 16
[pxx,f]=periodogram(B,nuttalwin(length(B),'periodic'),length(B),fs);
subplot(4,4,15);
plot(f,pxx);
hold on
otherwise
warning('Unexpected number typed. No windows is used ');
end
break;
end
我的目标是,使用循环我想在每一步,从1到输入一些号码16,并使用周期图与几个功率谱密度的subpplot不同的窗口,但是当我运行,它只显示我只绘制一次,这意味着例如,如果我输入数字1,它显示我韩窗然后停止,我怎么可以使循环通过每一步,并在同一时间保持之前绘制的图?提前致谢
感谢您的帮助,大小如何?我如何放大每个窗口的大小? –