How to substitute jw for s in a transfer function in Matlab?

조회 수: 54 (최근 30일)
Shane Palmer
Shane Palmer 2020년 6월 3일
답변: Star Strider 2020년 6월 3일
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);

채택된 답변

Star Strider
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개)

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by