0% found this document useful (0 votes)
46 views

Matlab: Presentation By: AMU ROBOCLUB

MATLAB is an interpreted programming language and environment for scientific computing. It allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages. MATLAB contains an integrated development environment and tools for algorithm development, data visualization, data analysis, and numeric computation. It supports various programming styles including procedural, object-oriented, and functional.

Uploaded by

suhani pandey
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Matlab: Presentation By: AMU ROBOCLUB

MATLAB is an interpreted programming language and environment for scientific computing. It allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages. MATLAB contains an integrated development environment and tools for algorithm development, data visualization, data analysis, and numeric computation. It supports various programming styles including procedural, object-oriented, and functional.

Uploaded by

suhani pandey
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 20

MATLAB

Presentation By : AMU ROBOCLUB


INTRODUCTION

Stands for MATrix LABoratory


Interpreted language
Scientific programming environment
Very good tool for the manipulation of
matrices
Great visualisation capabilities
Loads of built-in functions
Easy to learn and simple to use
The MATLAB System
Development Environment
Mathematics Function Library
MATLAB Language
Application Programming Language
MATLAB Desktop
Getting Help
There are several ways of getting help:-
Basic help on named commands/functions
is echoed to the command window by:
>> help command-name
A complete help system containing full text
of manuals is started by:
>> doc
Workspace
MATLAB maintains an active workspace,
any variables (data) loaded or defined
here are always available.
Some commands to examine workspace,
move around, etc:
who : lists variables in workspace
>> who

Your variables are:

x y
Workspace(Cont..)
Can manipulate variables stored in the
workspace
>> b=10;
>> c=a+b
c=
22
>>
Variables
Dont have to declare type
Dont even have to initialise
Just assign in command window
>>
>> a=12; % variable a is assigned 12
Matlab comment
prompt operator
suppress
assign
command
operator
output
Variables (Cont..)
View variable contents by simply typing the
variable name at the command prompt
>> a
a=
12
>>
>> a*2
a=
24
>>
Matrices
Dont need to initialise type, or dimensions
>>A = [3 2 1; 5 1 0; 2 1 7]
A=
3 2 1
5 1 0
2 1 7
>>
Manipulating Matrices
Access elements of a matrix
A=
3 2 1
5 1 0
>>A(1,2) 2 1 7

ans=
2
Remember Matrix(row, column)
Naming convention Matrix variables start
with a capital letter while vectors or scalar
variables start with a simple letter
Basic Operators
+, -, *, / : basic numeric operators
\ : left division (matrix division)
^ : raise to power
: transpose (of matrix) flip along
diagonal
fliplr(), flipud() : flip matrix about
vertical and horizontal axes.
The : Operator
VERY important operator in Matlab
Means to
>> 1:10
ans =
1 2 3 4 5 6 7 8 9 10
>> 1:2:10
ans =
1 3 5 7 9
The : Operator and Matrices
>>A(3,2:3) A=
3 2 1
ans = 5 1 0
2 1 7
1 7
>>A(:,2)
ans =
2
1
1
Manipulating Matrices A=
3 2 1
>> A ' % transpose 5 1 0
2 1 7
>> B*A % matrix multiplication
>> B.*A % element by element multiplication
>> B/A % matrix division B=
1 3 1
>> B./A % element by element division 4 9 5
>> [B A] % Join matrices (horizontally) 2 7 2

>> [B; A] % Join matrices (vertically)


Scripts
Matlab editor
Use scripts to execute a series of
Matlab commands

Matlab Desktop
Press to create new
m-file in the matlab
editor
Scripts(Cont..)
Scripts will manipulate and store variables and matrices
in the Matlab Workspace (memory).
They can be called from the Matlab command line by
typing the (case sensitive!) filename of the script file.
>> myscript
Scripts can be opened in the editor by the following
>> open myscript
Saving Data
MATLAB uses its own platform independent file
format for saving data files have a .mat
extension
The save command saves variables from
the workspace to a named file (or matlab.mat
if no filename given)
save filename saves entire workspace to
filename.mat
save var1 var2 filename saves named
variables to filename.mat
Saving Data(Cont..)

By default save overwrites an existing file of the same


name, the append switch forces appending data to
an existing file (but variables of same name will be
overwritten!)
save var1 var2 filename -append
Thank You

You might also like