Applications of MATLAB and Introduction To Simulink
Applications of MATLAB and Introduction To Simulink
By V V S Narayana Medasani
Application of MATLAB in fundamental signal generation: Fundamental signals: 1. Unit impulse 2. Unit step 3. Ramp
Output:
>> dirac(0) ans = Inf >> dirac(1) ans = 0 >> dirac(-1) ans = 0
Output:
Output:
Output:
Output:
U = pi*dirac(f) - i/f
Note: simplify(u)
ans = heaviside(t)
Output:
U = pi*(dirac(f - 1) + dirac(f + 1))
Output:
u = (1/exp(t*i))/2 + exp(t*i)/2
ans = cos(t)
Output:
U = 1/s
Output:
u = 1
Output:
U = s/(s^2 + 1)
Output:
u = cos(t)
Example (Z-Transform):
MATLAB code:
syms n z u=2^n; U=ztrans(u)
Output:
U = z/(z - 2)
Output:
u = 2^n
Output:
Output:
Note:
[gm,pm,wcg,wcp]=margin(sys)
Output:
MATLAB code:
M = [1100 800;1233 650; 1111 1001; 1222 1300; 999 1221]; save data.txt M -Ascii load data.txt disp(data)
Output:
1100 1233 1111 1222 999 800 650 1001 1300 1221
MATLAB code:
M = [1100 800;1233 650; 1111 1001; 1222 1300; 999 1221]; save data.txt M -Ascii load data.txt T =rot90(data)
Output:
T = 800 1100 650 1233 1001 1111 1300 1222 1221 999
Output:
Enter a value:1 The entered value is: '1'
Output:
D = 9*x^2
I = 3*x^3
Starting of Simulink:
Simulink runs under Matlab. First start Matlab, then type simulink at the Matlab prompt (Or) By directly click on Simulink icon
Simulink Library:
The first window that pops up is the Library Browser.
This is a library of blocks that are available for putting into the Simulink block diagram.
Simulink Library:
A Simulink model is a block diagram. Click File-New-Model in the Library Browser or press Ctrl+N. An empty block diagram will pop up. You can drag blocks into the diagram from the library.
Simulink Sources:
Select sources from the library. Drag any block you want to use into the model.
Simulink Sinks:
Select sinks from the library. Drag any block you want to use into the model.
Connecting blocks:
Drag a signal line from the output of a block to the input of another block. (or) Ctrl-Click will automatically connect.
You often have to zoom out using the binocular icon if the curve doesnt fit in the default axes.
Adding comments:
You can add text comments anywhere in the block diagram by double clicking and typing in some text. You can change the default comments under the blocks by double clicking and editing the text.
Signal Routing:
You can create a branch point in a signal line by holding down the CTRL key, and clicking on the line.
A summer block can be found in the commonly used blocks library, and in the math library.
Signal Routing:
To change the shape of the summer to rectangular, or to add additional inputs or change the sign, double click on the summer.
You can flip a block over by right clicking and looking under Format, or by selecting it and typing CTRL-i
Signal Routing:
Under the signal routing library, the MUX block can be used to bundle a group of signals together into a single line.
The DEMUX block does the reverse. This can be useful to send multiple signals to the same scope; then both signals will be displayed on the same plot.
Transfer Functions:
You set the transfer function numerator and denominator polynomials by double-clicking on the transfer function block.
Transfer Functions:
U s H s 1 s 1 s 1 1 s s 1
Y s U s H s
Integrators:
For integrators, you can set the initial condition and limit the output to not be allowed to go above or below some value on the properties for that block.
Queries.
The End