Session 1. Getting started with MATLAB/ Simulink
Lecture notes for Advanced modeling and Control
General functions: | |
cd |
Change subdirectory |
demo |
Launch the demo (introduction) |
dir (what) |
Listof files in currentdirectory (or only M-files) |
help, helpwin |
Help! Help window |
load |
Load workspace |
lookfor |
Keyword search |
print |
Printgraph; can use pull-down menu |
quit |
Quit! |
save |
Save workspace |
who, whos |
Listof variables in workspace |
Calculation functions: | |
conv |
Convolution function to multiply polynomials |
size, length |
Size of an array, length of a vector |
Plotting functions: | |
axis |
Override axis defaultof plot |
grid |
Add grid to plot |
hold |
Hold a figure to add more plots (curves) |
legend |
Add legend to plot |
plot |
Make plots |
text (gtext) |
Add text (graphical control) to plot |
title |
Add title to plot |
xlabel, ylabel |
Add axis labels to plot |
Partial fraction and transfer functions: | |
poly |
Construct a polynomial from its roots |
residue |
Partial-fraction expansion |
roots |
Find the roots to a polynomial |
tf2zp |
Transfer function to zero-pole form conversion |
zp2tf |
Zero-pole form to transfer function conversion |
tf |
Create a transfer function object |
get |
Listthe objectproperties |
pole |
Find the poles of a transfer function |
zpk |
Create a transfer function in pole-zero-gain form |
Activities
Explore MATLAB user interface
Define a vector
x = [1 2 3 4 5 6 7 8 9 10]
.What are different ways you can define x? What happens when you put ; at the end?
Convert vector
x
into a column vector.Create vector
y = [0, 0.1, 0.2, ...., 2.0]
Create a 3 x 3 matrix.
Print the size of the matrix and lengths of vectors defined so far.
Define 3 polynomials
Calculate
Perform some mathematical computations on the vectors, matrices, and polynomials defined so far.
Solve Ax = b
A = [ 4 -2 -10; 2 10 -12; -4 -6 16];
b = [-10; 32; -16];
Check the solution
Calculate eigenvalues and eigenvectors.
Consider data:
x = [ 0 1 2 4 6 10];
y = [ 1 7 23 109 307 1231];
Fit a third-order polynomial. Plot the results
Explore MATLAB plotting capabilities
Create a MATLAB script, save, and load it to plot data in item 13.
Find roots of polynomial defined by
p = [1 5 4]
Search for a function to find roots of a nonlinear equation.
Find polynomial for the roots (-4, -1)
For the following transfer functions find partial fractions.
Have fun with
zp2tf
,tf2zp
, andtf
commandsResponse of first order system: Compute and plot step response of following first order systems
Response of second order system: Compute and plot step response of following second order system. Show effect of
on response. ; ;Solve differential equations using Simulink
An object falling under gravity
Compare the result with analytical solution
Systems of ODEs
Citation
@online{utikar2023,
author = {Utikar, Ranjeet},
title = {Session 1. {Getting} Started with {MATLAB/} {Simulink}},
date = {2023-07-08},
url = {https://amc.smilelab.dev//content/notes/01-recap/in-class-activities.html},
langid = {en}
}