Not sure why my code isn't working. Please help
Mostrar comentarios más antiguos
I'm entering the following code and I cant seem to figure out why it won't run. Please help
%%%%%%%%%%%%%%%%******************%%%%%%%%%%%%%%
function [M,P]=fil_ters(R,C,f)% Function definition
w=2*pi*f;% Hz to rad/sec
G=1./(1j*w*R*C+1);% Transfer function
M=abs(G);% Magnitude
P=angle(G);% Phase
end
R=1000;% Resistance value
fc=10e3;% Cutoff frequency
C=1/(2*pi*R*fc);% Capacitance value
f=1:100000;% Frequency axis
[M,P]=fil_ters(R,C,f);%Function call
subplot(2,1,1);
semilogx(f,M);% Plot magnitude
xlabel('Frequency');
ylabel('Magnitude');
title('Magnitude plot');
grid;
subplot(2,1,2);
semilogx(f,rad2deg(P));% Plot phase
xlabel('Frequency');
ylabel('Phase(degree)');
title('Phase plot');
grid;
%%%%%%%%%%%%%%%%******************%%%%%%%%%%%%%%%
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Subplots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
