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

Matlab Introduction 1

MATLAB is a high-level programming language for numerical computation, visualization, and programming. It is developed by MathWorks and allows matrix manipulation, data plotting, algorithm implementation, user interface creation, and interfacing with programs in other languages. Common uses of MATLAB include signal processing, image and video processing, control systems, test and measurement, and computational finance. The MATLAB environment behaves like a complex calculator where commands are entered at the command prompt and executed immediately. It supports variables, operators, formatting, and saving/loading of workspaces.
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)
14 views

Matlab Introduction 1

MATLAB is a high-level programming language for numerical computation, visualization, and programming. It is developed by MathWorks and allows matrix manipulation, data plotting, algorithm implementation, user interface creation, and interfacing with programs in other languages. Common uses of MATLAB include signal processing, image and video processing, control systems, test and measurement, and computational finance. The MATLAB environment behaves like a complex calculator where commands are entered at the command prompt and executed immediately. It supports variables, operators, formatting, and saving/loading of workspaces.
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/ 24

Matlab

MATLAB - Overview
Overview
• MATLAB (matrix laboratory) is a fourth-generation high-level
programming language and interactive environment for numerical
computation, visualization and programming.

• MATLAB is developed by MathWorks.

• It allows matrix manipulations; plotting of functions and data;


implementation of algorithms; creation of user interfaces; interfacing
with programs written in other languages
Common Uses
• Signal Processing and Communications
• Image and Video Processing
• Control Systems
• Test and Measurement
• Computational Finance
Matlab Panels
• Current Folder − This panel allows you to
access the project folders and files.

• Command Window − This is the main


area where commands can be entered at
the command line. It is indicated by the
command prompt (>>).
Matlab Panels
• Workspace − The workspace shows all
the variables created and/or imported
from files.

• Command History − This panel shows or


return commands that are entered at the
command line.
MATLAB - Basic Syntax
• MATLAB environment behaves like a super-
complex calculator. You can enter
commands at the >> command prompt.

• MATLAB is an interpreted environment. In


other words, you give a command and
MATLAB executes it right away.
Basic Syntax
Special Variables and Constants
• MATLAB supports the following special variables and constants
Naming Variables
• Variable names consist of a letter followed by any number of letters,
digits or underscore.

• MATLAB is case-sensitive.

• Variable names can be of any length, however, MATLAB uses only first
N characters, where N is given by the function namelengthmax.
Use of Semicolon (;) and Comment
• Semicolon (;) indicates end of
statement. However, if you want to
suppress and hide the MATLAB
output for an expression, add a
semicolon after the expression.

• The percent symbol (%) is used for


indicating a comment line.
Common Operators and Special Characters
Common Operators and Special Characters
Common Operators and Special Characters
Relational Operators
Saving Your Work
• The save command is used for
saving all the variables in the
workspace, as a file with .mat
extension, in the current directory.

• You can reload the file anytime


later using the load command.
MATLAB - Variables
• In MATLAB environment, every variable is an array or matrix. You can
assign variables in a simple way.

• It creates a 1-by-1 matrix named x and stores the value 3 in its


element.
MATLAB - Variables
• Once a variable is entered into the
system, you can refer to it later.

• Variables must have values before they


are used.

• When an expression returns a result that


is not assigned to any variable, the
system assigns it to a variable named ans,
which can be used later.
MATLAB - Variables
• MATLAB will execute the statement
and return the result.

• You can have multiple assignments


on the same line
MATLAB - Variables
• The who command displays all the
variable names you have used. This is
useful if you have forgotten the variable
names.

• The whos command displays little more


about the variables
• Variables currently in memory
• Type of each variables
• Memory allocated to each variable
• Whether they are complex variables or not
MATLAB - Variables
• The clear command deletes all (or the specified) variable(s) from the
memory.

• Long assignments can be extended to another line


by using an ellipses (...).
Format
• By default, MATLAB displays numbers
with four decimal place values. This is
known as short format.

• However, if you want more precision,


you need to use the format command.

• The format long command displays 16


digits after decimal.
Format
• The format bank command rounds
numbers to two decimal places.

• MATLAB displays large numbers using


exponential notation.

• The format short e command allows


displaying in exponential form with four
decimal places plus the exponent.
Format
• Format long e

• format rat command gives the closest


rational expression resulting from a
calculation.

You might also like