0 Matlab Intro
0 Matlab Intro
1
MATLAB® /Simulink® is a powerful
software tool for:
Performing mathematical computations
and signal processing
What is
Analyzing and visualizing data (excellent
MATLAB graphics tools)
®? Modeling physical systems and
phenomena
Testing engineering designs
Aircraft/Defense: control and guidance system
design and simulation, communications
Robotics: design and control
Application
s (con’t)
Computers: security Financial: portfolio
systems, printer design management and risk,
commodity trading, currency
markets
MATLAB® Desktop
The Command window is where you type MATLAB
commands following the prompt: EDU>>
Command
History
Command Working
Window Memory
MATLAB Desktop
Order of
• 1. Complete all calculations inside parenthesis or
>> 10/5*2
>> 5*2^3+4(2)
Arithmetic Operators and
Some Examples: Order of Operations
>> -1^4
>> 8^1/3
Variables
In the previous exercise, you probably typed in
a value for pi.
MATLAB has a built-in variable for pi. Try this:
>> pi
Variables
You can even create your own variables. Try this:
>> radius = 4
x = 73.65
What happens?
The old value for x (10.57) is replaced by the new value (73.65)
Also, since the semicolon was left off the end, we see the result
in the command window (as well as in the workspace window)
Exercise 2
1. In MATLAB create two variables: a = 4 and b = 17.2
2. Now use MATLAB to perform the following set of
calculations:
5*a
Displaying Variables
We can display a variable (i.e., show its value) by simply
typing the name of the variable at the command prompt
(leaving off the semicolon). Try this!
>> y = 42;
>> FavoriteDay = ‘Friday’
• In script:
• z=1:99;
• average(z)
Polynomials
• We can use an array to represent a polynomial. To do so we use list
the coefficients in decreasing order of the powers. For example
x3+4x+15 will look like [1 0 4 15]
• x+5y+15z=7
• x-3y+13z=3
• 3x-4y-15z=11
Circumference = 25.13 cm
Exercise 1: New Script File
Right click in the current folder window in MATLAB
and create a new folder named whatever you
would like.
Double click on the folder to make it your current
folder.
Clear your MATLAB workspace by typing clear
at the command prompt.
Click on New Script to open a blank script file.
Type the commands on the next slide into the
editor window then save the file as CircleScript in
your newly created folder.
Exercise 1: Script File