Introduction to MATLAB
What is MATLAB?
• MATLAB is a programming language and environment used for
numerical computing and data analysis.
• It excels at matrix manipulations, data visualization, algorithm
implementation, and creating user interfaces.
Uses
• Engineering- Modeling and Simulation, Signal and Image Processing,
Control System Design, Finite Element Analysis (FEA)
• Science- Data Analysis and Visualization, Scientific Computing, Image
and Signal Processing
• Mathematics- Linear Algebra, Numerical Methods, Mathematical
Modeling, Data Analysis and Statistics
Basic MATLAB Interface
MATLAB as a Calculator
Basic Operations
• Addition (+)
• Subtraction (-)
• Multiplication (*)
• Division (/)
• Exponentiation (^)
• Built-in Functions
1. Square root- sqrt()
2. Absolute value- abs()
3. Trigonometric functions- sin() cos() tan()
Creating Scripts
• Open a new script file (Ctrl+N).
• Write your MATLAB code in the file.
• Save the file with a .m extension (e.g., example.m)
• Run the script from the command window.
Note:
MATLAB is case-sensitive.
Use semicolons at the end of a line to suppress output.
use comments to explain your code (lines starting with %).
Plotting Graphs
• Creating a Simple Linear Graph in MATLAB
• to plot a linear equation y = 2x + 1
• The plot command in MATLAB is used to create 2D line plots
• plot(x, y)
• Additional Options
• Line styles- ‘-’, '--’, ‘:’, '-.'
• Marker styles- ‘.’, ‘o’, ‘x’, '+'
• Colors- ‘r’, ‘g’, ‘b’, 'k'
• Multiple Plots
Matrices and Arrays in MATLAB
• MATLAB is fundamentally a matrix laboratory.
What is a Matrix?
A matrix is a two-dimensional array of numbers. It has rows and
columns.
What is an Array?
• In MATLAB, all variables are multidimensional arrays. A matrix is a
specific type of two-dimensional array. Arrays can have any number of
dimensions.
Matrix Operations
• MATLAB supports various matrix operations:
• Addition and subtraction
• Multiplication
• Division
• Transpose
• Inverse
• Determinant
MATLAB Applications:
• Engineering and Science
• Mathematics
• Finance
• Machine Learning, Deep Learning, Image and Video Processing,
Bioinformatics, Telecommunications