0% found this document useful (0 votes)
13 views29 pages

Matlap P.P

Uploaded by

hm24gdv4dr
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)
13 views29 pages

Matlap P.P

Uploaded by

hm24gdv4dr
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/ 29

What is MATLAB?

• MATMATLAB is a tool for technical computing,


computation and visualization in an
eintegrateenvironment. MATLAB is an
abbreviation for MATrix LABoratory, so it is
well suited for matrix manipulation and
problem solving related to Linear Algebra. LAB
is a short-term for MATrix LABoratory.
The MATLAB Environment
The MATLAB Environment consists of
the following main parts:
• Command Window
• Command History
• Workspace
• Current Folder
• Editor
Command Window
• The Command Window is the main window in
MATLAB. Use the Command Window to enter
variables and to run functions and M-files
scripts
2 Command History
• Statements you enter in the Command
Window are logged in the Command History.
From the Command History, you can view and
search for previously run statements, as well
as copy and execute selected statements. You
can also create an M-file from selected
statements.
2.3 Workspace
• The Workspace window list all your variables
used as long you have MATLAB opened.
Current Folder
• The “Current Folder” window lists all m files,
etc. available in the current directory
Basic Operations
• variables can be assigned without declaring
their type, and that their type can change.
Values can come from constants, from
computation involving values of other
variables, or from the output of a function.
Note
• The variables 𝑥 and 𝑋 are not the same.
• Unlike many other languages, where the semicolon is
used to terminate commands, in MATLAB the
semicolon serves to suppress the output of the line
that it concludes.
when you type a semicolon (;) after the command,
MATLAB will not respond. This is very useful because
sometimes you want MATLAB to respond, while in
other situations that is not necessary
Entering multiple statements per line
• It is possible to enter multiple statements per line.
Use commas (,) or semicolons (;) to enter more than
one statement at once. Commas (,) allow multiple
statements per line without suppressing output.
>> a=7; b=cos(a), c=cosh(a)
b=
0.6570
c=
548.3170
Built-in constants:
Miscellaneous commands
• it is possible for the results of one problem to have
an effect on the next one. To avoid this possibility,
it is a good idea to issue a clear command at the
start of each new independent calculation
• >> clear
• The command clear or clear all removes all
variables from the workspace. This frees up system
memory. In order to display a list of the variables
currently in the memory, type
>> who

while, whos will give more details which include


size, space allocation, and class of the variables
>> clc
To clear the Command Window, type clc
Getting help To view the online documentation,
select MATLAB Help from Help menu or MATLAB
Help directly in the Command Window. The
preferred method is to use the Help Browser. The
Help Browser can be started by selecting the ? icon
from the desktop toolbar. On the other hand,
information about any command is available by
typing
>> help Command
Use on-line help to request info on a specific
function
>> help sqrt
>> doc plot
In the current version (MATLAB version 7), the
doc function opens the on-line version of the
help manual. This is very helpful for more
complex commands.
>> lookfor
Use lookfor to find functions by keywords. The
general form is >> lookfor FunctionName
Matrix generation
• to enter a row vector, v, type
>> v = [1 4 7 10 13]
v=
1 4 7 10 13
• v(1) is the first element of vector v, v(2) its second element,
and so forth. Furthermore, to access blocks of elements, we
use MATLAB’s colon notation (:). For example, to access the
first three elements of v, we write,
>> v(1:3)
ans =
1 4 7
• Column vectors are created in a similar way, however,
semicolon (;) must separate the components of a
column vector,
• >> w = [1;4;7;10;13]
• w=
1
4
7
10
13
Entering a matrix
• A matrix is an array of numbers. To type a
matrix into MATLAB you must
• begin with a square bracket, [
• separate elements in a row with spaces or
commas (,)
• use a semicolon (;) to separate rows
• end the matrix with another square bracket, ]
Once we have entered the matrix, it is automatically
stored and remembered in the Workspace. We can
refer to it simply as matrix A. We can then view a
particular element in a matrix by specifying its location.
We write,
Colon operator in a matrix
• The colon operator can also be used to pick
out a certain row or column. For example, the
statement A(m:n,k:l specifies rows m to n and
column k to l. Subscript expressions refer to
portions of a matrix. For example,
Creating a sub-matrix
Deleting row or column
• To delete a row or column of a matrix, use the
empty vector operator, [ ].

Third row of matrix A is now deleted. To restore the third row, we use a technique for
creating a matrix
Transposing a matrix
• The transpose operation is denoted by an
apostrophe or a single quote (’). It flips a
matrix about its main diagonal and it turns a
row vector into a column vector. Thus,

You might also like