INTRODUCTION TO MATLAB Lecture 1
INTRODUCTION TO MATLAB Lecture 1
INTRODUCTION TO MATLAB Lecture 1
• Limitation
– Symbolic calculation: It also support symbolic calculation but with
certain limitation.
– Mathematica Software is Software used for strong and efficient
symbolic calculation
MATLAB LAYOUT
Default Layout of MATLAB
• Address bar
• Current folder
– Show all folders and files
• Command Window
– Starts with “ >>”” , all commands execute here !!
• Command History
– Show all previous commands with date
• Workspace
– Display all of the variable
• Layout can be changes as per user’s choice using
“Layout” option
File Type
• There are mainly three types of file in
MATLAB
– M-files
– MAT-files
– MEX-files
File Type
• M-files
– M-files are standard ASCII text files.
– File name of M-files are with extension (.m).
– Any program written in a MATLAB editor is
saved as M-files.
– These files are further classified as
• Script file
• Function file
File Type
• Script file
– It is a file written in matlab editor to solve the given
problem and saved with extension .m
» File can be executed by two ways
• Typing file name in command window (Be
careful about folder location)
• Using the icon RUN ( ) provided in
MATLAB
File Type
• Function file
– It is a file written in matlab editor using special
syntax
– Function file can be used called in other
script/function file
– Saved with extension .m
– Function file can be executed by writing file name
and required input parameters
– Details of function file will be discussed in coming
session
File Type
• MAT-files
– MAT-file is binary file used to save the data.
– Thus it is recognized as Data File
– MAT-file can be read by MATLAB environment
– Save with extension “.mat”
– MAT-files are double-precision MATLAB format files.
– They can be created on one machine and later read by
MATLAB on another machine with a different floating-point
format, retaining as much accuracy and range as the different
formats allow.
– They can also be manipulated by other programs external to
MATLAB.
– Working of MAT-files will be discussed in coming lectures
File Type
• MEX-files
– A MEX file is a function, created in MATLAB,
that calls a C/C++ program or a Fortran
subroutine. A MEX function behaves just like
a MATLAB script or function.
– Students are advised to read about this as per their
own interest.
OUTPUT DISPLAY
• format
– format long: Display 15 places after decimal
– format short: Display 4 places after decimal
– format long e: Display 15 places after decimal
followed by exponential
– format short e: Display 4 places after decimal
followed by exponential
– format long g: Total 15 digits
– format short g: Total 5 digits