Subscript indices must either be real positive integers or logicals.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Matt J
2021년 3월 18일
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
Matt J
2021년 3월 18일
You're welcome, but please Accept-click the answer if it resolved your question.
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!