How can I plot transfer function?

조회 수: 407 (최근 30일)
Tom
Tom 2023년 6월 27일
댓글: Star Strider 2024년 8월 29일
Hi,How could I plot a transfer function (Magnitude (Amplitude),Phase) which has maybe complex zeros and poles. For example H=s/((s+1)*(s+2)).

채택된 답변

Star Strider
Star Strider 2023년 6월 28일
You can use the transfer function that you posted, if you define ‘s’ first, using the tf function.
If you want the magnitude and phase matrices, and frequency vectors, use bode, since it can produce all those, however it has llimited plotting interactivity. For more extensive plot options, use bodeplot
s = tf('s');
H=s/((s+1)*(s+2))
H = s ------------- s^2 + 3 s + 2 Continuous-time transfer function.
figure
bode(H)
grid
figure
h = bodeplot(H);
grid
opts = getoptions(h);
opts.FreqUnits = 'Hz';
setoptions(h,opts)
See the relevant function documentation for details.
.
  댓글 수: 11
Lakshminarayanan
Lakshminarayanan 2024년 8월 29일
Thanks
Star Strider
Star Strider 2024년 8월 29일
My pleasure!
A Vote would be appreciated!

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

추가 답변 (1개)

ProblemSolver
ProblemSolver 2023년 6월 27일
To plot the magnitude and phase of a transfer function with complex zeros and poles in MATLAB, you can use the bode function.
% Define the transfer function
num = [1 0]; % Numerator coefficients for s
den = [1 3 2]; % Denominator coefficients for s
% Create the transfer function object
H = tf(num, den);
% Plot the magnitude and phase using the bode function
bode(H);
This code will generate a plot with two subplots: one for the magnitude (amplitude) and one for the phase response of the transfer function. The frequency range of the plot is determined automatically based on the system dynamics. You can customize the plot further by modifying the properties of the bode function. For example, you can specify a frequency range using the bode(H, w) syntax, where w is a vector of frequencies at which to evaluate the transfer function. Additionally, you can use the subplot function to create separate plots for magnitude and phase if you prefer individual plots rather than subplots.
  댓글 수: 4
Tom
Tom 2023년 6월 28일

ProblemSolver

I wanna something like this...

Paul
Paul 2023년 6월 28일
which can be very simply achieved using the solution in this answer, with one modification.
bode w/o output arguments won't meet the need, but one can always use the output arguments and then plot manually.
[m,p] = bode(tf_model, frequency_range);
plot(frequency_range,db(abs(squeeze(m)))),grid % and similar for phase

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

카테고리

Help CenterFile Exchange에서 Time and Frequency Domain Analysis에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by