Matlab- Find num and den

Thread Starter

cloud

Joined Dec 15, 2006
11
I have a transfer function called tf(1:43001). How do I obtain the
numerator and the denominator, so that I can use fvtool(num,den)?

Thank you.
 

Dave

Joined Nov 17, 2003
6,969
I cannot be specific beacuse I haven't got your transfer function to hand, but you could use the numden function in the Symbolic Math Toolbox (most Matlab installations have this installed as standard).

Rich (BB code):
[n,d] = numden(tf);
Will return the numerator, n, and the denominator d.

Failing that you could probably look at deriving the numerator and denominator during the derivation of the transfer function. Could you load up you code to let us have a look at it?

Dave
 

Thread Starter

cloud

Joined Dec 15, 2006
11
Attached is my code. I will like to find the num and den of my transfer function to design into a filter and to obtain an accurate frequency response. Do you have any suggestions to derive an accurate frequency response for my code?

Thank you.
 

Attachments

Papabravo

Joined Feb 24, 2006
21,225
I have a transfer function called tf(1:43001). How do I obtain the
numerator and the denominator, so that I can use fvtool(num,den)?

Thank you.
Does that notation imply that the numerator is a 1, and
the denominator is the polynomial 4x^4 + 3x^3 + 1 ?
So your question is how to get matlab to give you the individual pieces?
 

Thread Starter

cloud

Joined Dec 15, 2006
11
My tf(1:43001) is refering to the transfer function from 1 data points to 43001 data points. (1:43001) is the number of data points.
 

Papabravo

Joined Feb 24, 2006
21,225
My tf(1:43001) is refering to the transfer function from 1 data points to 43001 data points. (1:43001) is the number of data points.
So this transfer function is defined by a dataset and you want to calculate a rational function with polynomials in the numerator and denominator. Assuming that such a rational approximation exists. I am familiar with polynomial fits but I'm not sure you can find rational approximations to arbitrary data.

Does your data set have singularities? If it does then those are the roots of the denominator polynomial. Multiply the factors together to get the denominator. Does your data set have zeros? If it does those are the roots of the numerator polynomial. Multiply the factors together to get the numerator polynomial. Except for a possible gain constant, the rest of the points are just floor sweepings and have nothing to do with the transfer function.
 

Dave

Joined Nov 17, 2003
6,969
Rich (BB code):
tf=Ysec400c./Ypri400c;  % transfer function=FFT(secondary) / FFT(primary)
Why is this the transfer function? The transfer function is defined as the output/input of the system H(s) = Y(s)/X(s), so is this correct?

From what I can gather about your data, tf will be a 1x43001 array of numbers - correct? Therefore you cannot deduce the numerator and denominator of the transfer function from this information. If tf is a 1x43001 array of s-plane parameters then Matlab will allow you to deduce the transfer function directly using the above method in my earlier post.

Can you write up what data is contained in tf(1:3) as an example?

Thanks.

Dave
 

Thread Starter

cloud

Joined Dec 15, 2006
11
Yes, my transfer function is output/input of my system, H(s) = Y(s)/X(s). My tf is a 1x43001 array of data points. I would like to find out the Y(s) and X(s) to represent it as for example, (eg (2s+1)/(s^2+2s+1)). Because I need to perform digital simulations( using Simulink or PSCAD) using the transfer function (eg (2s+1)/(s^2+2s+1)).
 

Papabravo

Joined Feb 24, 2006
21,225
Yes, my transfer function is output/input of my system, H(s) = Y(s)/X(s). My tf is a 1x43001 array of data points. I would like to find out the Y(s) and X(s) to represent it as for example, (eg (2s+1)/(s^2+2s+1)). Because I need to perform digital simulations( using Simulink or PSCAD) using the transfer function (eg (2s+1)/(s^2+2s+1)).
One more time with feeling
The points are irrelevant. Only the poles and zeros matter.
 

Dave

Joined Nov 17, 2003
6,969
One more time with feeling
The points are irrelevant. Only the poles and zeros matter.
I concur, from analysing your code the tf array will not provide you the necessary information to derive the transfer function and hence the numerator/denominator for the function fvtool.

I am also not convinced that dividing your two solutions to the FFT for the secondary and primary constitutes the necessary requirements of the transfer function H(s).

Dave
 

Dave

Joined Nov 17, 2003
6,969
Since my tf=Ysec400c./Ypri400c, how do I represent Ysec400c and Ypri400c into a polynomial respectively?
Try this as a proposal, I'm not sure how it will work.

You want H(s) = Y(s)/X(s)

So: Y(s) = X(s)H(s)

Think of this in the time-domain: y[n] = x[n]*h[n] (this is convolution)

You effectly want to perform a deconvolution, Matlab lets you do this with the deconv function:

Rich (BB code):
[h,r] = deconv(y,x);
Where r is the remainder vector such that y = conv(x,h)+r (hopefully r will be a zero vector, i.e. all zeros).

The array h is now your impulse response, where by taking the Fourier Transform of h gives the transfer function.

Dave
 
Top