# matlab code help (tf)

Discussion in 'Programmer's Corner' started by suzuki, Apr 2, 2012.

1. ### suzuki Thread Starter Member

Aug 10, 2011
119
0
Hi, I want to write a transfer function in matlab. I know we usually write in the following way

trans = tf([1 0 0], [1 0 1]);
This gives something as a function of 's'.

what if i wanted to write an equation that was a function of 's+x', where x is a constant. So instead of H(s), i want to write a function and evaluate at values of say H(s+5).

thanks

2. ### steveb Senior Member

Jul 3, 2008
2,431
469
The numbers you use for the vectors in the "tf" command can be variables too. For example, the following would be allowed.

A=1;
B=0;
C=0;
D=1;
E=0;
F=1;
trans = tf([A B C], [D E F]);

3. ### suzuki Thread Starter Member

Aug 10, 2011
119
0
hmm, sorry, but i might have not been clear with my question. I see in the case you listed above that you can define the coefficients as variables. In my case, what i desire is that instead of computing

s^2/ s^2+1

i want to compute

(s+j5)^2/((s+j5)^2+1)

is this possible?

edit: on second thought, i could probably expand the polynomial in this case, but if this was a nth order polynomial, that may not be convenient, so i'd still like to know how to code this function, thanks

edit edit: now that i have actually expanded the polynomial, i find that i know longer have a function of 's', rather, i am left with a bunch of real numbers. can i still use the bode() and tf() calls here?

Last edited: Apr 2, 2012
4. ### steveb Senior Member

Jul 3, 2008
2,431
469
I'm not following what you are trying to do.

5. ### MrChips Moderator

Oct 2, 2009
19,033
6,114
Not quite sure what is your question.

Have you actually tried this in Matlab?

You can type

s = 2

s + 5i

or

s + 5j

(s+5j)^2/((s+5j)^2+1)

6. ### Georacer Moderator

Nov 25, 2009
5,154
1,281
I probably don't see the real issue here, but if you want to evaluate H(s+5) you could transform your variable:

Code ( (Unknown Language)):
1.
2. input=10;
3. trans_input=input+5;
4. H(trans_input);
5.
If, however, you want to use the tf function to evaluate the shifted-polynomial transfer function, you might need to play a bit with the polynomial functions library. I 'll get back to you when I get home.