how can I transform this code into a for loop

1 visualización (últimos 30 días)
Moussa Fofana
Moussa Fofana el 21 de Feb. de 2019
Comentada: Matt J el 24 de Feb. de 2019
subplot(3,3,1)
[S,f]=myFFT (x(0.1*fs:0.35*fs),fs);
plot(f,abs(S))
subplot(3,3,2)
[S,f]=myFFT (x(0.4*fs:0.65*fs),fs);
plot(f,abs(S))
subplot(3,3,3)
[S,f]=myFFT (x(0.7*fs:0.95*fs),fs);
plot(f,abs(S))
subplot(3,3,4)
[S,f]=myFFT (x(1.3*fs:1.55*fs),fs);
plot(f,abs(S))
subplot(3,3,5)
[S,f]=myFFT (x(1.6*fs:1.85*fs),fs);
plot(f,abs(S))
subplot(3,3,6)
[S,f]=myFFT (x(1.9*fs:2.15*fs),fs);
plot(f,abs(S))
subplot(3,3,7)
[S,f]=myFFT (x(2.2*fs:2.45*fs),fs);
plot(f,abs(S))
subplot(3,3,8)
[S,f]=myFFT (x(2.5*fs:2.75*fs),fs);
plot(f,abs(S))
subplot(3,3,9)
[S,f]=myFFT (x(2.8*fs:3.05*fs),fs);
plot(f,abs(S))

Respuesta aceptada

Matt J
Matt J el 21 de Feb. de 2019
Editada: Matt J el 21 de Feb. de 2019
a=[0.1, 0.3, 0.6, 1.3, 1.6, 1.9, 2.2, 2.5, 2.8];
b=a+0.25;
for i=1:9
subplot(3,3,i);
[S,f]=myFFT( x( a(i)*fs : b(i)*fs ) , fs);
plot(f,abs(S))
end
  2 comentarios
Moussa Fofana
Moussa Fofana el 24 de Feb. de 2019
Thank you!!!
Matt J
Matt J el 24 de Feb. de 2019
You're welcome, but please Accept-click the answer, since it seems to have solved your problem.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by