use while loop in matlab -
let consider following code
clear all; b=xlsread('data_generations1','a1','g8:g301'); % n=input('enter number 1 16 windows in periodogram :'); fs=input('enter sampling frequency fs :'); while 1 n=input('enter number 1 16 windows in periodogram :'); switch n case 1 disp('this 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 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 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 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 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 used '); end break; end
my goal using loop want enter @ each step number 1 16 , make subpplot of power spectral density using periodogram several different windows,but when run,it shows me plotting 1 times,that means example if enter number 1,it shows me hann window , stop,how can make loop through each step , @ same time keep plotted graph?thanks in advance
remove break
call. whole point of break
exit out of loop. since don't want exit early, don't call break
.
Comments
Post a Comment