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

Experiment No.5 Starting With MATLAB Program

The document discusses starting with MATLAB programs. It introduces MATLAB and its desktop components. It then covers generating vectors and matrices, referencing entries, deleting rows and columns, matrix division, entry-wise operations, matrix building functions, control flow statements, variable controlled loops, and plotting in MATLAB.

Uploaded by

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

Experiment No.5 Starting With MATLAB Program

The document discusses starting with MATLAB programs. It introduces MATLAB and its desktop components. It then covers generating vectors and matrices, referencing entries, deleting rows and columns, matrix division, entry-wise operations, matrix building functions, control flow statements, variable controlled loops, and plotting in MATLAB.

Uploaded by

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

Multimedia Computing Lab. Ruaa Hussam Al-Mallah /Lecturer Asst.

Computer Technical Eng. Dept.


4th Class
Experiment No.5
Starting with MATLAB program

Introduction:
MATLAB® (MATrix LABoratory) is a high-level language and interactive environment for
numerical computation, visualization, and programming. Using MATLAB, you can analyze data,
develop algorithms, and create models and applications. The language, tools, and built-in math
functions enable you to explore multiple approaches and reach a solution faster than with
spreadsheets or traditional programming languages, such as C/C++ or Java®. You can use
MATLAB for a range of applications, including signal processing and communications, image
and video processing, control systems, test and measurement, computational finance, and
computational biology. More than a million engineers and scientists in industry and academia
use MATLAB, the language of technical computing.
1. Command window.
2. Figure window : this window only pops up whenever you plot something.
3. Editor window: This window is used for writing and editing MATLAB programs (called
M-files) and can be invoked in Windows from the pull-down menu after selecting File |
New | M-file

The desktop includes these panels as illustrated in Fig 1


1. Current Folder — Access your files.
2. Command Window — Enter commands at the command line, indicated by the prompt
(>>).
3. Workspace — Explore data that you create or import from files
1. The MatLab system : The MATLAB system consists of these main parts:
1. Desktop Tools and Development Environment:
2. Mathematical Function Library
3. The Language
4. Graphics
5. External Interfaces

2- Hierarchy of arithmetic operations:

First The contents of all parentheses are evaluated first stage


second All exponentials are evaluated, working from left to right.
Third All multiplications and divisions are evaluated, working from left right.
Fourth All additions and subtractions are evaluated, starting from left to right.
3- Variable:

1. Variable names are case sensitive


2. Variable names can contain up to 63 characters
3. Variable names must start with a letter followed by letters, digits, and
underscores.
4. MatLab Special Variables:

EXP.No.5 :Starting with Matlab program Page 7


Multimedia Computing Lab. Ruaa Hussam Al-Mallah /Lecturer Asst.
Computer Technical Eng. Dept.
4th Class
ans Default variable name for result
Pi Value of π
Inf Infinity number
NaN Not a Number as 0/0 ‫رقم غير معرف‬
I and j The imaginary unit of square root of -1√
4- Workspace:
We can have many variable and function in our workspace .To see what variable we have
, type
Command function
Who To see what variable we have
whos To see the size (number of rows and columns) of the variable
clc Clear the command window
Clear var1 Clear only the variable var1
Clear Clear (delete) all variables in the workspace
Quit or exit Exit matlab
Procedure:

1- Generating Vectors and the Colon Notation: We can create a 1D vector directly as
1- Row Vector : for example
>> a= [1 2 3]
a=
1 2 3
2- Column Vector : for example

We could also from a vector by using the colon (: ) operator. “Colon Notation " is used to
generate vectors and to reference sub matrices. The colon notation and subscripting by
integral vectors and keys to efficient manipulation in MATLAB. Creative use of these
features to factorize operations lets you minimize the use of loops (which slows MATLAB
down) and makes code simple and readable

We could also use any increment to construct matrices (The increment put in the middle)

EXP.No.5 :Starting with Matlab program Page 8


Multimedia Computing Lab. Ruaa Hussam Al-Mallah /Lecturer Asst.
Computer Technical Eng. Dept.
4th Class

3- Generating Matrices: Column matrices can be created with the semicolon ( ; )

2- Referencing Individual Entries: Round parentheses are used to reference individual


elements of a matrix

The colon notation can be used to access submatrices of a matrix. For example:

p(1:2,3) is the column vector consisting of the first 2 entries of the 3rd column of matrix p.

3- Deleting Rows and Columns: You can delete rows and columns from a matrix using just a
pair of square brackets. Start with

EXP.No.5 :Starting with Matlab program Page 9


Multimedia Computing Lab. Ruaa Hussam Al-Mallah /Lecturer Asst.
Computer Technical Eng. Dept.
4th Class

4- Matrix Division

If A is an invertible square matrix and b is a compatible column vector, or respectively a


compatible row vector,

then x=A\b is the solution of A*x = b

x= b/A is the solution of x*A=b

5- Entry-Wise Operations:

EXP.No.5 :Starting with Matlab program Page 10


Multimedia Computing Lab. Ruaa Hussam Al-Mallah /Lecturer Asst.
Computer Technical Eng. Dept.
4th Class

6- Matrix Building Functions:

EXP.No.5 :Starting with Matlab program Page 11


Multimedia Computing Lab. Ruaa Hussam Al-Mallah /Lecturer Asst.
Computer Technical Eng. Dept.
4th Class
7- Control Flow Statements:
Relations:

8- Varaible Controlled Loops:

1-For:

2- While:

3- Branching (If):

EXP.No.5 :Starting with Matlab program Page 12


Multimedia Computing Lab. Ruaa Hussam Al-Mallah /Lecturer Asst.
Computer Technical Eng. Dept.
4th Class

4- Switch:

9- Plotting:
1- Basic Two-Dimensional Plot:

2-

EXP.No.5 :Starting with Matlab program Page 13


Multimedia Computing Lab. Ruaa Hussam Al-Mallah /Lecturer Asst.
Computer Technical Eng. Dept.
4th Class
3-

4-

Report:
1- what is the output of the following commands?

2-

3- How you will represent this equation in MatLab?

EXP.No.5 :Starting with Matlab program Page 14

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