本帖最后由 何必强求 于 2014-5-14 22:00 编辑
下面是一个显示并联谐振电路的阻抗特性曲线的程序,因为没有学过matlab,但最近的作业得用matlab编程。
只能写一些最基础的语句,希望懂的人能够帮忙简化一下,应该会用到循环,子程序什么的,最后几条曲线一定得在同一个图里哦
十分感谢!
%并联谐振回路阻抗特性function [] = ZvsW1() C = 10e-12; %电容100PF L = 5e-3; %电感10mH R1=10e3; R2=20e3; R3=30e3; R4=40e3;
w01 = 1/sqrt(L*C)*sqrt(1-R1*C/L); %谐振频率 w02 = 1/sqrt(L*C)*sqrt(1-R2*C/L); w03 = 1/sqrt(L*C)*sqrt(1-R3*C/L); w04 = 1/sqrt(L*C)*sqrt(1-R4*C/L); w1 = 0.01 : w01/100 : 2.0*w01; %频率扫描范围0.7-1.4w,这里没有考虑完全对称 w2 = 0.01 : w02/100 : 2.0*w02; w3= 0.01 : w03/100 : 2.0*w03; w4= 0.01 : w04/100 : 2.0*w04; n1 = length(w1); n2 = length(w2); n3 = length(w3); n4 = length(w4); for i = 1:n1 Z1(i) = ((R1+ j*w1(i)*L)*(1/(j*w1(i)*C)))/(R1 + j*w1(i)*L +1/(j* w1(i)*C)); end for i = 1:n2 Z2(i) = ((R2+ j*w2(i)*L)*(1/(j*w2(i)*C)))/(R2 + j*w2(i)*L +1/(j* w2(i)*C)); end for i = 1:n3 Z3(i) = ((R3+ j*w3(i)*L)*(1/(j*w3(i)*C)))/(R3 + j*w3(i)*L +1/(j* w3(i)*C)); end for i = 1:n4 Z4(i) = ((R4+ j*w4(i)*L)*(1/(j*w4(i)*C)))/(R4 + j*w4(i)*L +1/(j* w4(i)*C)); end figure; plot(w1/w01, abs(Z1),w2/w02,abs(Z2),w3/w03,abs(Z3),w4/w04,abs(Z4)); legend('R=10K','R=20K','R=30K','R=40K'); title('并联谐振回路阻抗幅度特性图1'); xlabel('频率(rad/s)'); ylabel('阻抗');
|