How to I plot Laplace transfer function characteristics using the symbolic toolbox?

조회 수: 16 (최근 30일)
Hi there,
I'd like to be able to use the symbolic toolbox for plotting the amplitude and phase response of a transfer function in the Laplace domain. Reason is because I find symbolic functions to keep my work neat and easily readable.
I've tried plotting the transfer functions' amp and phase characteristics using the following piece of code. Transfer function H describes a simple passive RC low pass filter where R*C = 0.001 in Vx = Vy + R*C*Vy*s.
syms s;
H = 1/(0.001*s+1);
figure; fplot(abs(H), [0 100000]);
figure; fplot(angle(H), [0 100000]);
I would expect the phase shift between Vy and Vx to go from 0 to -pi/2 (or -90 deg), as in the bode plot below:
bode([0 1], [0.001 1]);
However, when plotting the angle with fplot I see no phase shift:
fplot(angle(H), [0 100000]);
I'd be glad if anyone could explain to me why bode and fplot give different results.
Thanks in advance!

채택된 답변

Star Strider
Star Strider 2020년 5월 19일
Here, ‘s’ needs to be complex:
syms s;
H = 1/(0.001*1j*s+1);
figure; fplot(20*log10(abs(H)), [0 100000]);
% set(gca, 'XScale','log')
figure; fplot(angle(H), [0 100000]);
% set(gca, 'XScale','log')
For some reason, setting the 'XScale' to 'log' (so that it matches the bode plot) fails for fplot plots. I will experiment with that and post back if I can figure out a way to get it to work.
  댓글 수: 3
Star Strider
Star Strider 2020년 5월 19일
As always, my pleasure!
Symbolic variables are ‘complex’ by definition, however by defaault the imaginary parts are equal to 0, making them real. I set ‘s’ to be purely imaginary in my code.
I also had no problems creating logarithmic x-axis (and y-axis) scaling, however I could not get it to work correctly when I converted ‘H’ to decibels and plotted the y-axis linearly after the transformation to dB, with logarithmic x-axis scaling. That is what I wanted to do, and could not.
Andrew Krill
Andrew Krill 2022년 6월 19일
Oh man, this entire thread was really helpful.
Thing I noticed,
figure; fplot(20*log10(abs(H)), [0 100000]);
Doesn't work, because log(0) is undefined.
figure; fplot(20*log10(abs(H)), [1 100000]);
Worked just fine.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by