Hi. I want creat a tranfer function have parameter,but i don't know how to do it.help me pls

 Accepted Answer

Hi super bad,
have a look into the matlab function "tf":
Kind regards,
Robert

4 Comments

Hi super bad,
asume you need to write a function with parameters a, b, and c that returns you a transfer function H(a,b,c) in Laplace domain:
function [ H ] = make_my_tf( a,b,c )
%MAKE_MY_TF creates a transfer function from parameters a,b, and c. It is
%restricted to systems of the fixed form below and returns the transfer function in
%Laplace domain.
%
% fixed transfer function: H(a,b,c) = ( a*s + 3 ) / (s^2 + b*s + c)
H = tf([a 3],[1 b c]);
end
Kind regards,
Robert
Just saw the discussion below. My answer comprises a function file. Star Strider gave it already as anonymous function.
Kind regards,
Robert
MATLAB cannot create a transfer function that displays like
a s + 3
--------------
s^2 + b s + c
with literal characters 'a' and 'b' and 'c' showing up, except as a symbolic expression like Star Strider shows.
If particular numeric values are to be substituted, so it might for example show up as
5 s + 3
--------------
s^2 - 2 s + 17.1
then that can be done with the methods Robert or Star Strider show.

Sign in to comment.

More Answers (2)

If you are creating a ‘tunable’ system, see the documentation on the realp (link) function.

11 Comments

No bro: I want creat tranfer function in command window of matlab . My problem is parameter (a b c)
Your question is ambiguous. It lacks details necessary to provide a specific solution.
Try this:
sys_fcn = @(a,b,c) tf([a 3], [1 b c]);
sys = sys_fcn(1,2,3);
bode(sys)
I want declare a b c in numeric form, and use them to set the transfer function.
sorry bro: it not true. you try it. a,b,c represents any number
a s + 3
--------------
s^2 + b s + c
I did try it, it is true, and I tested all the code I posted here to be certain it works (in R2017b) before I posted it. I am out of ideas for solving your ambiguous problem.
Good luck!
thank bro so much.But I still can not do it, do not know why. hihi...i use matlab V65.
The only documentation I can find for V6.5 is for V6.5.2: LTI Models (link), probably the 2005 version. It seems that you should be able to use the last code I posted.
My last effort (before I completely give up):
sys_fcn = inline('tf([a 3],[1 b c])', 'a','b','c');
sys = sys_fcn(1,2,3);
This works in 2017b. I do not have access to V6.5, so I cannot test it with your version. MathWorks folks may have to solve your problem.
Your ways are not right for me. My teacher wants to have the end result:
a s + 3
--------------
s^2 + b s + c
You never mentioned that as a specific requirement before.
What you want to do is not possible other than in the Symbolic Math Toolbox:
syms a b c s
sys = (a*s + 3)/(s^2 + b*s + c)
pretty(sys)
a s + 3
------------
2
s + b s + c
Stopping here.
Again, Good luck!

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!