Subscript indices must either be real positive integers or logicals.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
The following is the code:
w=-20:0.1:20;
T= 0:0.1:1;
j=sqrt(-1);
F(i)=(1-exp(-j*w(i)*T(i)))./(j*w(i));
A=abs(F); % Amplitue Spectrum
P=angle(F); % Phase Spectrum
subplot(2,1,1), plot(w,A), xlabel('frequency'), ylabel('amplitude'),
title(' Amplitude Spectrum')
subplot(2,1,2), plot(w,P), xlabel('frequency'), ylabel('Angle')
title(' Phase Spectrum')
I am getting error as
"Subscript indices must either be real positive integers or logicals"
Can anyone help me out of this ?
0 comentarios
Respuestas (1)
Matt J
el 18 de Mzo. de 2021
I don't get errors, as long as i is a real loop counter.
w=linspace(-20,20,50);
T= linspace(0,1,50);
for i=1:50
F(i)=(1-exp(-1j*w(i)*T(i)))./(j*w(i));
end
A=abs(F); % Amplitue Spectrum
P=angle(F); % Phase Spectrum
subplot(2,1,1), plot(w,A), xlabel('frequency'), ylabel('amplitude'),
title(' Amplitude Spectrum')
subplot(2,1,2), plot(w,P), xlabel('frequency'), ylabel('Angle')
title(' Phase Spectrum')
2 comentarios
Matt J
el 18 de Mzo. de 2021
You're welcome, but please Accept-click the answer if it resolved your question.
Ver también
Categorías
Más información sobre Subplots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!