Introduction to MATLAB
Objective: To introduce engineering undergraduates to MATLAB’s basic functions, user
interface, and its application in engineering problems.
Introduction
MATLAB, which stands for "Matrix Laboratory," is a powerful computational tool widely used
in the field of engineering. As an interactive programming environment, it allows engineers to
perform complex mathematical analyses, visualize data, and develop algorithms, all within a user-
friendly interface. Designed around matrices, MATLAB simplifies the handling of mathematical
operations, making it an invaluable resource for engineering undergraduates. Whether you're
simulating systems, analyzing signal data, or solving differential equations, MATLAB provides a
robust platform to address a broad spectrum of engineering challenges.
Basics of MATLAB Environment
MATLAB Desktop overview: Command Window, Workspace, Command History, and Current
Folder.
Simple arithmetic operations examples:
i. 5+6 ii. 7*8 iii. 9/3
MATLAB Variables and Data Types
• Variables • Data Types
matrix = [1, 2; 3, 4]
a = 10
scalar = 42
b=5
stringVar = "Hello, MATLAB!"
c=a+b
cellArray = {1, 'a'; 'MATLAB', [1, 2, 3]}
MATLAB Scripting Basics
• Simple Loop: • Conditional Loop:
for i = 1:5 if a > b
disp(['Iteration: ', disp('a is greater than b')
num2str(i)])
else
end
disp('b is greater than or equal to a')
end
Plotting Basics
• 2D Plot:
x = linspace(0, 2*pi, 100);
y = sin(x);
plot(x, y)
xlabel('x')
ylabel('sin(x)')
title('Simple Sin Wave')
• 3D Plot:
[X, Y] = meshgrid(-5:0.5:5, -5:0.5:5);
Z = X.^2 + Y.^2;
surf(X, Y, Z)
Basic Functions
Funtion to Calculate area of a circle:
function A = circle_area(radius)
A = pi * radius^2;
end
Applications in Engineering
• Solving linear equations
A = [2, 5; 7, 4];
B = [8; 10];
X = A \ B;
• Finding roots of equations
• Optimization problems
• Introduction to toolboxes such as Signal Processing, Control Systems, etc