Making a line thought points plotted from for loop in MATLAB

2 visualizaciones (últimos 30 días)
I am trying to connect the data points that are obtained from the following code, but am not able to. How do I connect the points?
clc;
clear all
R1= 1399.580e+6;
C1= 374.868e-6;
R2= 1497.005e+6;
C2= 350.472e-6;
R3= 19573.407e+6;
C3= 2429.373e-12;
R0= 1354.967e+6;
C0= 15.94e-9;
hold on
for f =[0.001 0.005 0.01 0.05 0.1 0.5 1 5 10 50 100 500 1000]
W = 2*pi*f;
Cr=(C0)+(C1)/(1+(W*R1*C1)^2)+(C2)/(1+(W*R2*C2)^2)+(C3)/(1+(W*R3*C3)^2);
Ci=1/(W*R0)+(W*R1*C1^2)/(1+(W*R1*C1)^2)+(W*R2*C2^2)/(1+(W*R2*C2)^2)+(W*R3*C3^2)/(1+(W*R3*C3)^2);
tan_del = Ci/Cr
f
set(gca, 'XScale', 'log')
plot([f],[tan_del],'-x','linewidth',10)
xlabel('Freq in log')
ylabel('tan_del in lin')
line(f,tan_del,'Color', 'r','linewidth',10)
end
hold off

Respuesta aceptada

Alan Stevens
Alan Stevens el 20 de Oct. de 2021
Like this?
R1= 1399.580e+6;
C1= 374.868e-6;
R2= 1497.005e+6;
C2= 350.472e-6;
R3= 19573.407e+6;
C3= 2429.373e-12;
R0= 1354.967e+6;
C0= 15.94e-9;
f =[0.001 0.005 0.01 0.05 0.1 0.5 1 5 10 50 100 500 1000];
W = 2*pi*f;
Cr=(C0)+(C1)./(1+(W*R1*C1).^2)+(C2)./(1+(W*R2*C2).^2)+(C3)./(1+(W*R3*C3).^2);
Ci=1./(W*R0)+(W*R1*C1^2)./(1+(W*R1*C1).^2)+(W*R2*C2^2)./(1+(W*R2*C2).^2)+(W*R3*C3^2)./(1+(W*R3*C3).^2);
tan_del = Ci./Cr;
semilogx(f,tan_del,'x',f,tan_del,'r')
xlabel('Freq in log')
ylabel('tan_del in lin')
  1 comentario
Siddhi Kadam
Siddhi Kadam el 20 de Oct. de 2021
Yes. Thank you so much. When I removed the for loop I was getting an error that matrix dimensions do not match. Yours is working very well. Thanks again.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by