An Introduction to MATLAB Lesson 1 - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

An Introduction to MATLAB Lesson 1

Description:

window. 1 to 5 different windows can be selected to appear ... Can run the program by typing its name in the command window or from tools in the editor window. ... – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 23
Provided by: fadh3
Category:

less

Transcript and Presenter's Notes

Title: An Introduction to MATLAB Lesson 1


1
An Introduction to MATLABLesson 1
  • Dr. Samir Al-Amer
  • Term 061

2
MATLAB
  • MATLABMATrix LABratory
  • It is widely used to solve different types of
    scientific problems.
  • The basic data structure is a complex double
    precision matrix.

3
Run MATLAB
  • From Start Menu
  • Select Programs
  • Select MATLAB

MATLAB Prompt Tells that MATLAB is ready for
your command
4
MATLAB Layout
  • 1 to 5 different windows can be selected to
    appear (View)

Current directory window
Command History window
Command window
5
MATLAB shortcuts
Help
SIMULINK
Open files
New file
6
MATLAB AS A CALCULATOR
Command window
gtgt 394.45 ans 176.6000
Command window
7
MATLAB
  • Variable names
  • Starts with a letter
  • Up to 31 characters ( some use 19 or 21)
  • May contain letters, digits and underscore_
  • Case sensitive (A is not the same as a)

8
MATLAB Assignment
  • Variable names
  • Starts with a letter
  • Up to 31 characters ( some use 19 or 21)
  • May contain letters, digits and underscore_
  • Case sensitive (A is not the same as a)
  • A2.3
  • A
  • 2.3000

9
Scalar Assignment
The square braces are used to define
matrices. We can use them for scalars too.
  • A2.3
  • A
  • 2.3000

10
Row vector
X2,3 7
X 2 3 7
11
Column vector
X23 7
X 2 3 7
12
MATLAB Statements
13
MATLAB Statements
14
Polynomials
15
Help
  • A good idea is use the help
  • help provides information about the available
    functions and how to use them.
  • Try
  • help eig
  • help inv
  • help roots

16
Programming in MATLAB
  • There are two types of MATLAB programs

script files
function files
script file P1 3 2 roots(P)
function yfun(x) yx23x22
17
Programming in MATLABScript files
  • A Script file contains a set of MATLAB command
  • Use them when you have a long sequence of
    statements to solve a problem
  • Can run the program by typing its name in the
    command window or from tools in the editor
    window.

18
Logical Operators
19
Logical Operators
if (Xgt6) (xlt3)
20
If structures
  • General form
  • If condition
  • statements
  • else
  • statements
  • end

If (xgt0) sign1 elseif (x0)
sign0 else sign-1 end
21
for loops
  • General form
  • for indexinitial increment limit
  • statements
  • end

s0 for i1311 ssi end
22
Example
  • MATLAB program to find the roots of

Result
X 1.1111 X 1.0483 X 1.0472 X
1.0472
program 1 performs four iterations of
Newtons Method X.7 for i14 XX
(2cos(X)-1)/(-2sin(X)) end
Write a Comment
User Comments (0)
About PowerShow.com