You are on page 1of 9

Introduction to

MATLAB and Simulink

• Lab Instructor: Engr. Syed Abuzar Bacha


Basic Commands
• % used to denote a comment
• ; suppresses display of value (when placed at
end of a statement)
• eps machine epsilon
• inf infinity
• NaN not-a number, e.g., 0/0.
Arithmetic with MATLAB
• Let us explore by doing exercises:

>> 3–2 <Enter>


>> 3*2 <Enter>
>> 3/2 <Enter>
>> 3^2 <Enter>
>> 2/0 <Enter>
>> 0/2 <Enter>
>> 3*Inf <Enter>
Algebraic-numeric computations
• Let us explore by doing exercises:
>> a = 3 <Enter>
>> b = 2 <Enter>
>> a – b <Enter>
>> a / b <Enter>
>> a^2 <Enter>
>> c = a * b <Enter>
>> d = c^(b+1) <Enter>
Matlab’s Workspace
• clear all – clear workspace vars.
• close all – close all figures
• clc – clear screen
• clf – clear figure
Numbers
• To change format of numbers:
format long, format short, etc.
See “help format”.
• Mathematical functions: sqrt(x), exp(x),
cos(x), sin(x), sum(x), etc.
• Operations: +, -, *, /
• Constants: pi, exp(1), etc.

You might also like