Error using semilogx Vectors must be the same length.
Afficher commentaires plus anciens
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)
Réponses (1)
Torsten
le 22 Avr 2023
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 commentaires
Walter Roberson
le 22 Avr 2023
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
le 22 Avr 2023
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!