Error using semilogx Vectors must be the same length.
이전 댓글 표시
Wondering why I'm getting the error at the end?
clc
close all
R = 10e3;
C = 18e-9;
Wb = 1/(R*C);
A=@ (w) 1./[1 -(Wb./w).^2 - 1i*2*Wb./w];
w = 10:10:1e6;
amp = 20*log10(abs(A(w)));
ang = angle(A(w))*180/pi;
subplot (211)
semilogx(w,amp,'b','linewidth',2)
grid on
title(char(A))
ylabel('Magnitude (DB)')
set(gca,'xscale','log')
subplot(212)
semilogx(w,ang,'r','linewidth',2)
grid on
set(gca,'xscale','log')
xlabel('frequency (rad/sec)')
ylabel ('phase (deg)')
__________________________________________________________________________________________
Error using semilogx
Vectors must be the same length.
Error in lab20cd3 (line 11)
semilogx(abs(w),abs(amp),'b','linewidth',2)
답변 (1개)
Torsten
2023년 4월 22일
Use
A=@ (w) 1./(1 -(Wb./w).^2 - 1i*2*Wb./w);
instead of
A=@ (w) 1./[1 -(Wb./w).^2 - 1i*2*Wb./w];
댓글 수: 2
Walter Roberson
2023년 4월 22일
Ah yes, inside [] spacing is important, and [1 -(Wb./w).^2 - 1i*2*Wb./w] would probably be interpreted as
horzcat(1, -(Wb./w).^2-1i*2*Wb./w)
Nicholas Armenti
2023년 4월 22일
카테고리
도움말 센터 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!