Professional Documents
Culture Documents
MatLab Basics
Engr. Ma. Fregie Gaile R. Pagador
mrpagador@mmsu.edu.ph
Instructor I
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