Solved. Thanks artikk!

tboo

Diamond Member
Jun 25, 2000
7,627
1
81
Im trying to create a function that will return a transfer function by inputting a pole &/or its complex conjugate. This would be for poles only-no zeros.

so if I enter func(-1) it will return : transfer function: 1/s^2+2s+1

Any help is appreciated. I suck at Matlab.
 
Last edited:

Saint Nick

Lifer
Jan 21, 2005
17,722
6
81
It was a joke buddy It's Friday...lighten up

Edit: Sorry if it came off as douchey Just making a joke!
 
Last edited:

busydude

Diamond Member
Feb 5, 2010
8,793
5
76
You are going to have infinite different answers for your problem. You need to be more specific.
 

tboo

Diamond Member
Jun 25, 2000
7,627
1
81
Ive tried several iterations. None have worked. Here is the latest:


function [num den p h] = rsys(x,y,z)
num =[0 0 1];
p=poly([x y z]);
den=p;
h=tf(num,den);
 
Last edited:

randomrogue

Diamond Member
Jan 15, 2011
5,462
0
0
Pro tip: Buy the book that has like every function and an explanation and example of it.

I made a really big mistake for a huge project where I wrote up a modeling program with multiple nested loops and checks only to find out that there was one line of code that I could have used. The only good news is that there were people dumber than me who used excel to do it and it took them 2 days to get an answer each time they tested it. That spreadsheet was the most ridiculous thing I think I ever saw in college and brought computers to their knees.
 

artikk

Diamond Member
Dec 24, 2004
4,172
1
71
You should have googled more. Anyway, here's my final response.
z = vector of zeros, form: z=[x y z]; In your case make it empty, e.g. z=[];
p=vector of poles, form: p=[x y z];
k=overall system gain, make it=1;
[num,den] = zp2tf(z,p,k)
then transform into transfer function
sys=tf(num, den);
 

tboo

Diamond Member
Jun 25, 2000
7,627
1
81
You should have googled more. Anyway, here's my final response.
z = vector of zeros, form: z=[x y z]; In your case make it empty, e.g. z=[];
p=vector of poles, form: p=[x y z];
k=overall system gain, make it=1;
[num,den] = zp2tf(z,p,k)
then transform into transfer function
sys=tf(num, den);

Will that work with complex numbers? For example, I need to be able to enter function(-8 -.5+.7071i -.5-.7071i) & get back transfer function: 1/s^3 +9s^2 +35/4s +6

I can do it in the command window using this:

num=[0 0 1];
>> p=poly([-8 -.5+.7071i -.5-.7071i]);
>> den=p;
>> tf(num,den)

Transfer function:
1
------------------------
s^3 + 9 s^2 + 8.75 s + 6


I just need to figure out how to turn it into a function where I enter the poles & get a transfer function back
 
Last edited:

artikk

Diamond Member
Dec 24, 2004
4,172
1
71
Will that work with complex numbers? For example, I need to be able to enter function(-8 -.5+.7071i -.5-.7071i) & get back transfer function: 1/s^3 +9s^2 +35/4s +6

I can do it in the command window using this:

num=[0 0 1];
>> p=poly([-8 -.5+.7071i -.5-.7071i]);
>> den=p;
>> tf(num,den);
>> tf(num,den)

Transfer function:
1
------------------------
s^3 + 9 s^2 + 8.75 s + 6


I just need to figure out how to turn it into a function where I enter the poles & get a transfer function back

The code that you showed does this already as a final step. Are you talking about making a custom function that uses the code above to output what you want? Because that would be really pointless just to save a couple of lines of code.
 
Last edited:

tboo

Diamond Member
Jun 25, 2000
7,627
1
81
The code that you showed does this already as a final step. Are you talking about making a custom function that uses the code above to output what you want? Because that would be really pointless just to save a couple of lines of code.

Yes, I need to make a custom function to give me a transfer function with whatever poles I enter(no zeros).
 

artikk

Diamond Member
Dec 24, 2004
4,172
1
71
Yes, I need to make a custom function to give me a transfer function with whatever poles I enter(no zeros).

DON'T FORGET TO DO THIS FIRST.
Save the code as .m file with filename given by the function name("pole_to_tf.m" in this case) and set path to it by going to File>Set Path...

Now here's the function's code:

function [tf_out] = pole_to_tf(poles)
%Calculates transfer function given
%inputs: poles
num=[0 0 1];
p=poly([poles]);
den=p;
tf_out=tf(num,den);

end

To see output just type(without semicolon):
tf_out=pole_to_tf([-8 -.5+.7071i -.5-.7071i])

Transfer function:
1
------------------------
s^3 + 9 s^2 + 8.75 s + 6

Phew, that was just tedious.
 

tboo

Diamond Member
Jun 25, 2000
7,627
1
81
DON'T FORGET TO DO THIS FIRST.
Save the code as .m file with filename given by the function name("pole_to_tf.m" in this case) and set path to it by going to File>Set Path...

Now here's the function's code:

function [tf_out] = pole_to_tf(poles)
%Calculates transfer function given
%inputs: poles
num=[0 0 1];
p=poly([poles]);
den=p;
tf_out=tf(num,den);

end

To see output just type(without semicolon):
tf_out=pole_to_tf([-8 -.5+.7071i -.5-.7071i])

Transfer function:
1
------------------------
s^3 + 9 s^2 + 8.75 s + 6

Phew, that was just tedious.

Thanks for your help artikk. Ill give it a try.
 

artikk

Diamond Member
Dec 24, 2004
4,172
1
71
Thanks for your help artikk. Ill give it a try.

After plugging in different poles and higher order poles, the function works for all iterations of poles given there are no zeros
 
Last edited:
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |