Making a line thought points plotted from for loop in MATLAB

조회 수: 3 (최근 30일)
Siddhi Kadam
Siddhi Kadam 2021년 10월 20일
댓글: Siddhi Kadam 2021년 10월 20일
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에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by