How to substitute jw for s in a transfer function in Matlab?
30 次查看(过去 30 天)
显示 更早的评论
Hello,
I am looking to easily substitute the complex number j*omega into the s variable within a transfer function that has been Laplace transformed.
This is my code, and I have poor matlab coding skills, I am sorry.
I have had to manually insert the coefficient values in another line "magT" because I don't know how to just directly swap "j*omega" for "s" in my "Transfer_func"
syms C R_1 R_2 R_3 L s V_o i omega
%Equations
R_1 = 10;
R_2 = 10;
R_3 = 10;
L = 0.001;
C = 2*10^-6;
Z_1 = R_1+L*s;
Z_2 = 1/(C*s)+R_2;
Z_3 = R_3;
Z_23 = 1/(1/(Z_2)+1/(Z_3));
Z_tot = Z_1+Z_23;
V_i = Z_1*i+V_o;
V_o = (V_i/(Z_1))/((1/((1/(C*s))+R_2))+1/R_3+1/(Z_1));
Transfer_func = simplify(V_o/V_i);
magT = sqrt((5.903*10^24)^2+(1.181*10^20*omega)^2)/sqrt((1.181*10^25-(2.361*10^16*omega^2))^2+(9.445*10^20*omega)^2);
0 个评论
采纳的回答
Star Strider
2020-6-3
Try this:
syms C R_1 R_2 R_3 L s V_o i omega
%Equations
R_1 = 10;
R_2 = 10;
R_3 = 10;
L = 0.001;
C = 2*10^-6;
Z_1 = R_1+L*s;
Z_2 = 1/(C*s)+R_2;
Z_3 = R_3;
Z_23 = 1/(1/(Z_2)+1/(Z_3));
Z_tot = Z_1+Z_23;
V_i = Z_1*i+V_o;
V_o = (V_i/(Z_1))/((1/((1/(C*s))+R_2))+1/R_3+1/(Z_1));
Transfer_func(s) = vpa(simplify(V_o/V_i), 5);
Transfer_func(omega) = subs(Transfer_func, {s},{1j*omega});
figure
subplot(2,1,1)
fplot(real(Transfer_func), [0 5E+4*pi], '--')
hold on
fplot(imag(Transfer_func), [0 5E+4*pi], '--')
fplot(abs(Transfer_func), [0 5E+4*pi])
hold off
legend('\Re', '\Im', '|H( j\omega )|')
title('Amplitude')
grid
subplot(2,1,2)
fplot(angle(Transfer_func), [0 5E+4*pi])
grid
title('Phase')
xlabel('Frequency (radians)')
It then uses fplot to evaluate the second version of the function, producing:
.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!