You are on page 1of 23

ME406L

Control Systems (Lab)


LABORATORY LEARNING MODULE : 1

GETTING TO KNOW MATLAB

Compiled and Prepared by: Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
Engr. Mervin E. Albalate, M. Sc. written permission of the Bulacan State University through its
Innovation and Technology Support Office (ITSO).
Electronics Engineering Department
You may reach the ITSO at the following
College of Engineering address: itso.rmo.rde@bulsu.edu.ph
Bulacan State University

Work of Government (2022) Bulacan State University


ME406L
INTENDED LEARNING OUTCOMES (ILO)

• • Familiarize with the use of MATLAB.

• • Perform basic MATLAB commands that are essential in mathematical and algebraical
applications

Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
MATLAB
• Stands for MATrix LABoratory
• A multi-paradigm numerical computing environment and
fourth-generation programming language.
• A proprietary programming language developed by MathWorks
• Current Release Version : R2022a
Sourced from: Wikipedia Publication Notice (2022).
This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
MATLAB USED FOR:
1. Matrix manipulations
2. Plotting of functions and data
3. Implementation of algorithms
4. Creation of user interfaces
5. Interfacing with programs written in other languages, including C, C++,
C#, Java, Fortran and Python
6. Simulation Applications Sourced from: Wikipedia
Publication Notice (2022).
This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
MATLAB ACCESS:
BulSU has acquired legit “MATLAB” subscription for the faculty and
students at the university via their google accounts (bulsu.edu.ph).
All students that have computer laboratories MUST be able to
register and install MATLAB for those who have computers.
Even those without computers can still use MATLAB online via
cellphone when registered.
Publication Notice (2022).
This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
MATLAB ENVIRONMENT

Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
MATLAB ENVIRONMENT

Current
Folder:
Shows the
current
directory that
MATLAB is
accessing.

Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
MATLAB ENVIRONMENT

Current Command Window :


Folder: : Area where user inputs
Shows the commands and views output
current responses by MATLAB.
directory that
MATLAB is
accessing.

Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
MATLAB ENVIRONMENT

Current Command Window : Workspace:


Folder: : Area where user inputs : Provides the
Shows the commands and views output user the
current responses by MATLAB. currently
directory that used variable,
MATLAB is its value and
accessing. its type.

Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
MATLAB ENVIRONMENT

Current Command Window : Workspace:


Folder: : Area where user inputs : Provides the
Shows the commands and views output user the
current responses by MATLAB. currently
directory that used variable,
MATLAB is its value and
accessing. its type.

Work of Government (2022) Bulacan State University


ME406L
USING
THE COMMAND
WINDOW
This is where the
“show begins”
You can type the
mathematical
operation
or function after the
“>>” prompt

Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
USING
THE COMMAND
WINDOW
There are two ways to
input command:
First one is without
semicolon
Let’s try :
1. Type command :
f=‘hello world’
2. Then press “Enter”
NOTICE:
The value of f is
assigned to a string of
characters (Strings).
Strings are input in
between apostrophes
(‘).
These (values) are
displayed immediately Publication Notice (2022).
This is a government work.

after pressing the No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

“Enter” key. Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
USING
THE COMMAND
WINDOW
There are two ways to
input command:
Second is with
semicolon ( ; )
Let’s try :
1. Type command:
g=‘hello world too’;
2. Then press “Enter”
NOTICE:
The value of g is also
assigned to a string of
characters.
But these (values) are
NOT displayed after
pressing “Enter”.
You are just moved to
the next line and Publication Notice (2022).
This is a government work.

prompted by “>>” No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
USING
THE COMMAND
WINDOW
DON’T WORRY g is still
assigned to the string
you typed.
DO :
1. Type command : g
2. Then press “Enter”
NOTICE:
The value of g is
displayed as output

Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
USING
THE COMMAND
WINDOW
CLEARING THE COMMAND
WINDOW:

DO :
1. Type command : clc;
2. Then press “Enter”

NOTICE: The screen is


cleared of the previous
display (including the
latest one ; clc;)
This command works also
without semicolon.

Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
USING
THE COMMAND
WINDOW
CLEARING THE COMMAND WINDOW:
DO :
1. Type command : clc;
2. Then press “Enter”
NOTICE: The screen is cleared of the previous display (including the latest one ; clc;)
This command works also without semicolon.

MATLAB Input Forms:


1. Strings
2. Numerical Values
3. Symbolic Arithmetic Values
4. Predefined Values
5. Functions
6. Arrays/Matrices
7. Vectors Publication Notice (2022).
This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
USING
THE COMMAND WINDOW:
NUMERICAL VALUES
Practically, we input numbers for
mathematical operations.
MATLAB at its simplest works
like a regular calculator.
However, you must type the
equation in a specific order or
hierarchy to get the right answer:

Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
USING
THE COMMAND WINDOW:
NUMERICAL VALUES
Precedence or Hierarchy of
Operation from highest to lowest
1. Parenthesis
2. Negation
3. Exponent or Raising to a Power
4. Multiplication or Division
5. Addition or Subtraction

Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
USING
THE COMMAND WINDOW:
NUMERICAL VALUES
Basic Mathematical Operation
1. Addition :+
2. Subtraction :–
3. Multiplication :*
4. Right Division : / (Normal Division – divides the numerator to the denominator)
5. Left Division : \ (Reverse Division – divides the denominator to the numerator)
6. Exponentiation : ^ (example: 83 : 8^3)

Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
USING
THE COMMAND WINDOW:
NUMERICAL VALUES
Basic built-in Mathematical Functions
Note : n here will represent the number.
1. Square root : sqrt(n)
2. Exponentials : exp(n)
if n=1, you’ll get Euler’s number e = exp(1)= 2.7183
3. Absolute Value : abs(n)
4. Natural Logarithm : log(n)
5. Base 10 Logarithm : log10(n)
6. Factorial : factorial(n) Publication Notice (2022).
This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
USING
THE COMMAND WINDOW:
NUMERICAL VALUES
Basic built-in Mathematical Functions
Note : n here will represent the angle in radians
1. Sine : sin(n) 1. Hyperbolic Sine : sinh(n)
2. Cosine : cos(n) 2. Hyperbolic Cosine : cosh(n)
3. Tangent : tan(n) 3. Hyperbolic Tangent : tanh(n)
4. Cotangent : cot(n) 4. Hyperbolic Cotangent : coth(n)
5. Secant : sec(n) 5. Hyperbolic Secant : sech(n)
6. Cosecant : csc(n) 6. Hyperbolic Cosecant : csch(n)
Publication Notice (2022).
This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
USING
THE COMMAND WINDOW:
NUMERICAL VALUES
Basic built-in Mathematical Functions
Note : n here will represent the angle in degrees
1. Sine : sind(n)
2. Cosine : cosd(n)
3. Tangent : tand(n) No hyperbolics using degrees
4. Cotangent : cotd(n)
5. Secant : secd(n)
6. Cosecant : cscd(n)
Publication Notice (2022).
This is a government work.
No part of this publication may be reproduced for profit without the
written permission of the Bulacan State University through its Innovation

Work of Government (2022) Bulacan State University and Technology Support Office (ITSO).
You may reach the ITSO at the following
address: itso.rmo.rde@bulsu.edu.ph
ME406L
LABORATORY LEARNING MODULE : 1
GETTING TO KNOW MATLAB

© MATHWORKS

Compiled and Prepared by: Publication Notice (2022).


This is a government work.
No part of this publication may be reproduced for profit without the
Engr. Mervin E. Albalate, M. Sc. written permission of the Bulacan State University through its
Innovation and Technology Support Office (ITSO).
Electronics Engineering Department
You may reach the ITSO at the following
College of Engineering address: itso.rmo.rde@bulsu.edu.ph
Bulacan State University

Work of Government (2022) Bulacan State University

You might also like