lab01_2

13
INTODUCTION TO MATLAB SIMPLE CALCULATION TO MATLAB 1

Transcript of lab01_2

•INTODUCTION TO MATLAB

•SIMPLE CALCULATION TO MATLAB

1

MATLAB is a tool which can be used to performed the numerical methods calculation. Whereby iteration can be done in a shorter time.

Besides MATLAB, EXCEL is also commonly used.

This course will look into both the MATLAB as the EXCEL.

2

In engineering field, MATLAB can be used to;

Determine the mathematical model that represent the real condition of the engineering situation. Using the determine mathematical model, data can be predicted without performing any experimental work.

3

In engineering field, MATLAB can be used to;

Determine the optimum condition of the engineering process. (eg.. the best temperature, pressure to get the maximum yield)

Determine the statistical data of the engineering work. (eg..the lowest yield, the average..)

4

For you as the student, MATLAB will be used in;

Process Modeling and Simulation

Research Project

5

Go to MATLAB icon

You will get to command window with the following sign

>>

Calculation can be done using the suitable signs within this command window

6

Some common mathematical operations in MATLAB

* (multiplication)/ (division)\ (inverse divition)^ (power or exponentiation)+ (addition)- (subtraction)

(when using power for vectors/matrices, a period (.) must come first before the operation ^)

7

Some common command in MATLAB

Use semicolon (;) as to suppress output for an expression.

Example:>>x=2>>y=4>>Z=X*Y

These can be simplified using (;) as>>x=2;y=4;Z=X*Y

8

Some common command in MATLAB

To list back all the variable that we have introduce we may simply type who or whos

>>who

>>X=2

Y=4

Z=X*Y

9

Some common command in MATLAB

To clear all the variable that you have state just type Clear, than all the variables will be erased.

If you want to erase only certain variables, type Clear – space-followed by the variables/s that you want to erase

10

Some common command in MATLAB

For long assignment or statement that you may require to continue to the next line you may use ellipsis (…)

11

Some common command in MATLAB

To get 4 decimal places:

>>format short

To get 16 digits:

>>format long

To get 2 decimal places

>>format blank

To get the closest rational expression

>>format rat

12

Some common mathematical definition and function

pi : π

exp(x) : e to the power of x

sqrt(x) : square root of x

log(x) : natural log of x

log10(x) : base 10 log of x

floor(x) : greatest integer less than x

ceil(x) : smallest integer greater than x

x can be scalar or vector

sin(x), cos(x), atan(x)…x must be in radian

13