step response from an equation

조회 수: 3 (최근 30일)
Juan Jose Ortiz Torres
Juan Jose Ortiz Torres 2018년 9월 21일
댓글: Dimitris Kalogiros 2018년 9월 21일
Hello guys.
I am makig a program to plot the step response of a transfer function. But my program starts defining the numerator and the denominator of the transfer function like the following:
if true
syms s
num_planta=1; %numerator of the transfer function
den_planta=s*(s+2); %denominator of the transfer function
end
Then I make the fraction
if true
transfer_fnc=num_planta/den_planta
end
Then with that variable I make a code works, but the code does not plot anything. So I decided to do it possible. So I use some techniques but nothing work. I am gonna explain the techniques, so if you can guide me, I will be grateful.
1. Using step(transfer_fcn)
if true
aux_transfer_fcn=transfer_fcn
SS=tf('s')
subs(transfer_fcn,s,SS)
step(aux_transfer_fcn)
end
But matlab says that I cannot substitute a "symbolic" variable to a "tf" variable
2. Making with matrix
if true
[num_transfer_fcn,den_transfer_fcn]=numden(transfer_fcn)
coefs_num_transfer_fcn=coeffs(num_transfer_fcn,s,'all')
coefs_den_transfer_fcn=coeffs(den_transfer_fcn,s,'all') %%so it will be [1, 2, 0]
system=tf(coefs_num_transfer_fcn,coefs_den_transfer_fcn)
end
But matlab does no accept matrices like [1,2,3] only [1 2 3], so I was looking up how to convert but I failed lot of times.
Could you please guide me?

답변 (1개)

Dimitris Kalogiros
Dimitris Kalogiros 2018년 9월 21일
Use this:
clear; clc;
close all;
% sympolic math toolbox
syms s,
num_planta=sym(1); %numerator of the transfer function
den_planta=s*(s+2); %denominator of the transfer function
transfer_fnc=num_planta/den_planta
%%extract coeffs of num and denum
nump=sym2poly(num_planta)
denp=sym2poly(den_planta)
%%create transfer function using control toolbox
H=tf(nump, denp);
step(H) % step function
If you run this, you should get:
  댓글 수: 2
Juan Jose Ortiz Torres
Juan Jose Ortiz Torres 2018년 9월 21일
Thank you very much! it works!!!
Dimitris Kalogiros
Dimitris Kalogiros 2018년 9월 21일
...then "accept" the answer :-)

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by