0% found this document useful (0 votes)
639 views63 pages

Introduction To Matlab

MATLAB is an integrated technical computing environment for engineers and scientists. It combines numeric computation, advanced graphics, a high-level programming language, and interactive tools for designing, problem-solving, and data visualization. MATLAB allows matrix manipulation, data analysis, algorithm development, and visualization of results through plots and graphs. It has built-in functions, toolboxes, and customizable GUIs for various applications.

Uploaded by

Anika dixit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
639 views63 pages

Introduction To Matlab

MATLAB is an integrated technical computing environment for engineers and scientists. It combines numeric computation, advanced graphics, a high-level programming language, and interactive tools for designing, problem-solving, and data visualization. MATLAB allows matrix manipulation, data analysis, algorithm development, and visualization of results through plots and graphs. It has built-in functions, toolboxes, and customizable GUIs for various applications.

Uploaded by

Anika dixit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 63

Introduction to Matlab

S K Chouksey
What is MATLAB?
Is an integrated technical computing
environment that combines numeric computation,
advanced graphics and visualization, and a high-
level programming language.

High-level language of technical computing


Development environment for engineers, scientists
Interactive tools for design, problem solving
Mathematical function libraries
Graphics and data visualization tools
Custom GUIs
External Interfaces: C, C++, Fortran, Java, COM, Excel, .NET

Introduction to Matlab S K Chouksey


Matlab
• 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

Introduction to Matlab S K Chouksey


Introduction to Matlab S K Chouksey
Matlab Desktop

Workspace /
Current Directory
Command
Window

Command
History

Introduction to Matlab S K Chouksey


Explore the Matlab Desktop
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Variables
• Don’t have to declare type
• Don’t even have to initialise
• Just assign in command window
>>
>> a=12; % variable a is assigned 12

Matlab comment
prompt suppress operator
assign
command
operator
output Try the same line without the
semicolon and comments
Introduction to Matlab S K Chouksey
Variables (continued …)
• View variable contents by simply typing the
variable name at the command prompt
>> a
a=
12
>>
>> a*2
a=
24
>>

Introduction to Matlab S K Chouksey


Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Manipulating Matrices A=
3 2 1

• Access elements of a matrix 5


2
1
1
0
7

>>A(1,2)
ans= indices of matrix element(s)
2
• Remember Matrix(row,column)
• Naming convention Matrix variables start
with a capital letter while vectors or scalar
variables start with a simple letter
Introduction to Matlab S K Chouksey
A=
3 2 1
Manipulating Matrices 5
2
1
1
0
7

>> A ' % transpose B=


1 3 1
>> B*A % matrix multiplication 4 9 5
>> B.*A % element by element multiplication 2 7 2

>> B/A % matrix division


Enter matrix B
>> B./A % element by element division into the Matlab
workspace
>> [B A] % Join matrices (horizontally)
>> [B; A] % Join matrices (vertically)

Create matrices A and B and try out the the matrix operators in this slide
Introduction to Matlab S K Chouksey
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
Try the following
ans = >> x=0:pi/12:2*pi;
>> y=sin(x)
1 3 5 7 9
Introduction to Matlab S K Chouksey
The : operator and matrices
A=
>>A(3,2:3) 3 2 1
ans = 5 1 0
2 1 7
1 7
>>A(:,2)
ans =
2
1
What’ll happen if you type A(:,:) ?
1

Introduction to Matlab S K Chouksey


Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Matlab help commands
• help
>> help whos % displays documentation for the function whos
>> lookfor convert % displays functions with convert in the first help line

• Start Matlab help documentation


>> helpdesk

Introduction to Matlab S K Chouksey


Matrices
• Don’t need to initialise type, or dimensions
>>A = [3 2 1; 5 1 0; 2 1 7]
A=
square brackets to define matrices
3 2 1
5 1 0 semicolon for next row in matrix
2 1 7
>>
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Plotting – creating & visualizing

Introduction to Matlab S K Chouksey


Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Automating commands – creating, saving & executing script file

Introduction to Matlab S K Chouksey


Introduction to Matlab S K Chouksey
Conditional control statements

Introduction to Matlab S K Chouksey


Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Introduction to Matlab S K Chouksey
Loop control statements

Introduction to Matlab S K Chouksey


Introduction to Matlab S K Chouksey
Reference
1. Getting started with MATLAB, A quick introduction for scientists and
engineers, Rudra Pratap, Indian edition

Introduction to Matlab S K Chouksey


Workspace
• The workspace is Matlab’s memory
• Can manipulate variables stored in the workspace
>> b=10;
>> c=a+b
c=
22
>>

Introduction to Matlab S K Chouksey


Workspace (continued …)
• Display contents of workspace
>> whos
Name Size Bytes Class
a 1x1 8 double array
b 1x1 8 double array
c 1x1 8 double array
Grand total is 3 elements using 24 bytes
>>

• Delete variable(s) from workspace


>> clear a b; % delete a and b from workspace
>> whos
>> clear all; % delete all variables from workspace
>> whos

Introduction to Matlab S K Chouksey

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy