You are on page 1of 15

ECE 101 Laboratory 1

MatLab Basics
Engr. Ma. Fregie Gaile R. Pagador
mrpagador@mmsu.edu.ph
Instructor I

COLLEGE OF ENGINEERING Department of Electronics Engineering


Introduction
MATLAB, which stands for Matrix Laboratory, is a very powerful program for
performing numerical and symbolic calculations, and is widely used in science and
engineering, as well as in mathematics.
• MATLAB is a technical language to ease scientific computations.
• The name is derived from MATrix LABoratory .
• It provides many of the attributes of spreadsheets and programming languages.
• MATLAB is a case sensitive language (a variable named “c” is different than another
one called “C”).
• In interactive mode MATLAB scripts are platform independent (good for cross
platform portability).
• MATLAB works with matrices.
• Everything MATLAB understands is a matrix (from text to large cell arrays and
structure arrays).
The (;), %, clc command
If a semicolon (;) is typed at the end of a command , the output of
the command is not displayed. If several commands are typed
in the same line, the output from any of the commands will not
be displayed if a semicolon is typed between the commands
instead of a comma.
When the percent symbol (%) is typed in the beginning of a line,
the line is designated as a comment. The % character followed
by text can also be typed after a command (in the same line).
This has no effect on the execution of the command.
The clc command, clears the command window.
Introduction

Current Folder Command Window Workspace

Command
History
Operators and Special Characters
Format
Operations and Conventions
• Expressions follow the standard order of precedence
- Exponentiation
- Multiplication and Division
- Addition and Subtraction
• Expressions are evaluated from left to the right
• Parentheses work from inner to outer
Operations and Conventions
Using MATLAB as a Calculator
-type the mathematical expression and press the enter key.
MATLAB calculates the expression and responds by
displaying ans = and the numerical result of the expression in
the next line.
>> 7 + 8/2 (enter key)
>> (7+8)/2 (enter key)
>> 27^(1/3) + 32^0.2 (enter key)
>>0.7854-(0.7854)^3/(1*2*3)+0.785^5/(1*2*3*4*5)…
-(0.785)^7/(1*2*3*4*5*6*7)
Examples
1. Evaluate tan−1 (3 − 2𝑥) if x = 30
1
2. Evaluate 700 (𝑥 3 − 9𝑥 2 + 6𝑥 − 20) at x = 5
3. Evaluate 𝑥 + 3 = 2𝑥 + 4 − 1 at x = - 2
1
(9812 )
4. Solve 54
56(8−6 )
sin(−23.55)
5. Solve
cot−1 (6.57)
Activity 1
tan−1 (3−2𝜋)
1. Evaluate sec(4+8𝜋)
16
2. Evaluate 1098
(−9𝑥 3 + 3𝑥 2 − 23𝑥 + 11) at x = 7
3
3. Evaluate 2𝑥 − 4 = −3𝑥 + 27 + 23 at x = 6
3
4515
4. Solve 23
75 8−9
(32 − 3−16 )
1/5
cot −8.25 1
5. Solve
csc−1 13.54 54
Defining Scalar Values
A variable is a name made of letter or a combination of
several letters (and digits) that is assigned a numerical
value. Once a variable is assigned a numerical value, it can
be used in mathematical expressions, in functions, and in
MATLAB statements and commands.
The assignment operator (=) assigns a value to a variable.
Variable_name=A numerical value, or a complete
expression
Rules about Variable Names
Variable names:
• Can be up to 63 characters long
• Can contain letters, digits, and the underscore character
• Must begin with a letter
• MATLAB is case sensitive
• Avoid using built-in function for a variable
• Predefined Variables:
1. ans – a variable that has the value of the last expression that was not assigned to a specific variable.
2. pi – the number pi.
3. eps – the smallet difference between two numbers.
4. inf – used for infinity
5. i – defined as square root of -1
6. j – same as i
7. NaN – stands for not-a-numnber
Get in Touch
With Us
Send us a message or
visit us
City of Batac, Ilocos Norte,
Philippines
(63) 77-600-0459
op@mmsu.edu.ph

Follow us for updates


facebook.com/MMSUofficial
www.mmsu.edu.ph

You might also like