Making a line thought points plotted from for loop in MATLAB

2 次查看(过去 30 天)
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

采纳的回答

Alan Stevens
Alan Stevens 2021-10-20
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 个评论
Siddhi Kadam
Siddhi Kadam 2021-10-20
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by