Transfer function matlab
Transfer function matlab
Control System Toolbox™ software supports transfer functions that are continuous-time or discrete-time, and SISO or MIMO. You can also have time delays in your transfer function representation.
A SISO continuous-time transfer function is expressed as the ratio:
G ( s ) = N ( s ) D ( s ) ,
of polynomials N( s) and D( s) , called the numerator and denominator polynomials, respectively.
You can represent linear systems as transfer functions in polynomial or factorized (zero-pole-gain) form. For example, the polynomial-form transfer function:
G ( s ) = s 2 − 3 s − 4 s 2 + 5 s + 6
can be rewritten in factorized form as:
G ( s ) = ( s + 1 ) ( s − 4 ) ( s + 2 ) ( s + 3 ) .
The tf model object represents transfer functions in polynomial form. The zpk model object represents transfer functions in factorized form.
MIMO transfer functions are arrays of SISO transfer functions. For example:
G ( s ) = [ s − 3 s + 4 s + 1 s + 2 ]
is a one-input, two output transfer function.
Commands for Creating Transfer Functions
Use the commands described in the following table to create transfer functions.
Create tf objects representing continuous-time or discrete-time transfer functions in polynomial form.
Create zpk objects representing continuous-time or discrete-time transfer functions in zero-pole-gain (factorized) form.
Create tf objects representing discrete-time transfer functions using digital signal processing (DSP) convention.
Create Transfer Function Using Numerator and Denominator Coefficients
This example shows how to create continuous-time single-input, single-output (SISO) transfer functions from their numerator and denominator coefficients using tf .
Create the transfer function G ( s ) = s s 2 + 3 s + 2 :
num and den are the numerator and denominator polynomial coefficients in descending powers of s. For example, den = [1 3 2] represents the denominator polynomial s 2 + 3 s + 2 .
G is a tf model object, which is a data container for representing transfer functions in polynomial form.
Alternatively, you can specify the transfer function G( s) as an expression in s:
Create a transfer function model for the variable s.
Specify G( s) as a ratio of polynomials in s.
Create Transfer Function Model Using Zeros, Poles, and Gain
This example shows how to create single-input, single-output (SISO) transfer functions in factored form using zpk .
Create the factored transfer function G ( s ) = 5 s ( s + 1 + i ) ( s + 1 − i ) ( s + 2 ) :
Z and P are the zeros and poles (the roots of the numerator and denominator, respectively). K is the gain of the factored form. For example, G( s) has a real pole at s = –2 and a pair of complex poles at s = –1 ± i. The vector P = [-1-1i -1+1i -2] specifies these pole locations.
G is a zpk model object, which is a data container for representing transfer functions in zero-pole-gain (factorized) form.
An easy way to create a transfer function in MATLAB involves using the command
to create s as a variable and then use s in a line of code to make a transfer function.
The feedback command in MATLAB takes plant and output sensor transfer functions (G and H in the Nise book’s paradigm) and produces the overall transfer function assuming negative feedback. Specifically, if G and H are defined as variables,
is functionally the same as:
The difference is, in the former case, MATLAB automatically checks for pole-zero cancellation. To make sure that MATLAB always checks for pole-zero cancellation, use the minreal command:
Very Basic Analytical
Assume you have a transfer function (mathbb
There are a few different ways to examine the magnitude and phase content of the Fourier version of this transfer function:
over a range of frequencies. This example will show how to use MATLAB’s tf function to set up and analyze the magnitude and phase of the transfer function of circuit. It will allow the bode command to generate the plot — including the choice of frequencies over which to plot.
More Advanced Analytical
The next example will show how to use MATLAB’s tf function to set up and analyze the magnitude and phase of the transfer function of circuit. It will also show the code to modify how the information is plotted, including changing the frequency domain over which the information is plotted..
Estimates from Time Series Data
If you have a data set and want to find an estimated experimental transfer function between two variables in the set, you can have MATLAB come up with a transfer function estimate using the tfestimate command. In the example below, assume you are trying to find an estimate for the transfer function:
to generate a magnitude plot and a phase plot of an experimentally determined transfer function. MATLAB’s tfestimate will produce a numerical estimate of the magnitude and phase of a transfer function given an input signal, an output signal, and possibly other information. The specific form of this command is:
- Vin — vector containing the input voltage values
- Vout — vector containing the output voltage values
- Fs — the sampling frequency for the voltage values, in Hz
- EstH — vector containing complex numbers that contain the amplitudes and phases of the estimate of the transfer function
- EstF — vector containing the corresponding frequencies, in Hz, for the magnitudes and phases stored in EstH
- EstMag — magnitude of the transfer function estimate
- EstPhase — phase of the transfer function estimate
- EstOmega — corresponding angular frequencies for the estimate values
The square brackets in the third through fifth arguments are placeholders for parameters whose default values are fine for this experiment. Essentially, this command will determine the frequency content of the input and of the output using subsections of the data; it will then compute the magnitude ratio and phase difference between the input and the output and provide an approximation of the transfer function at particular frequencies contained in EstF.
One issue that comes into play is you must make sure the input signal has energy at as many frequencies as possible to give tfestimate values to work with. Using a single-frequency cosine as an input, for example, might lead to a disaster — if that frequency happens to exactly hit one of the frequencies tfestimate is using — since there would only be one input frequency on which to base an estimate for the response to all frequencies. This would be similar to estimating the acoustics of a concert hall by hitting a single tuning fork.
It is important to note, however, that what MATLAB is really doing is assuming that your input is one period’s worth of some periodic input — meaning (T) is (
To make a plot, you can use code similar to:
transfer function and bode plot in matlab
basics of transfer function and bode plot in matlab
- MATLAB Projects
- transfer function and bode plot…
in this tutorial we will learn transfer function and bode plot in matlab.Bode Plot is the commonly known analysis and design technique employed in the design of the Linear Time Invariant (LTI) system. Bode Plot compliance the complete information about the frequency response of the Linear Time Invariant System but do so in the graphical domain. That is the Bode plot consists of the Bode Magnitude Plot of the LTI system and the Bode Phase Plot of the system. Bode Magnitude Plot gives the information about the relationship between the system input frequency and the magnitude of the output of the system and on the other hand the magnitude phase plot contains the information of the variation of the phase of the output with respect to the corresponding variation in the system input signal.
Bode plot in MATLAB:
The Bode Plot can be considered as the visualization of the frequency response of the System as the frequency response of the system contains the knowledge about the variation of the output magnitude and phase with respect to the range of the frequencies of the input signal. The frequency response of the system is usually represented in terms of the complex frequency variable. The general representation of the frequency response of the system is shown in the figure below:
As shown in the figure above the frequency response of the system can be thought of as the transfer function of the system in the frequency domain. The equation above shows the relationship between the input and the output of the system in terms of the frequency variable. It can be noted that the frequency response which is basically the transfer function can be obtained by taking the Laplace transform of the time domain representation of the system or by taking the Fourier transform of the time domain representation of the system.
Transfer Function in MATLAB:
As noted previously that the transfer function represents the input and output of the system in terms of the complex frequency variable so that the transfer function can give the complete information about the frequency response of the system. It is important that we have the transfer function of the system in order to analyze the system in the frequency domain. There are various techniques with the help of which we can obtain the transfer function of the LTI system one is the Laplace transform and the other Fourier Transform. There is not much difference between the Laplace transform and the Fourier transform. To be precise the Laplace transform is the general representation of the Fourier Transform. The Laplace transform converts the time domain representation of the system in the frequency domain in which the variation of the frequency variable determines the behavior of the overall system.
Keeping in mind the importance of the transfer function there should be some handy way of representing the Transfer Function in MATLAB which is commonly used tool in analysis and design. Let us now discuss the transfer function representation of the system in the MATLAB with the help of some examples.
The above mentioned transfer function can be represented in the MATLAB as follows:
Now let us consider another example: