English-Tutorial-5: Arithmetic operation in MATLAB-2013a

Arithmetic operation:

 

 

For basic familiar with data managing on MATLAB you need to know the special arithmetic operator in the MATLAB. They are +, -, *, / and .

Data handling: Now we will go to MATLAB and see how to manage data with using that type of arithmetic operator.

Run MATLAB, and open editor window by clicking New Script.

 

 1

 

*** Type the following codes for use arithmetic operator (+):

clc;

 

clear all;

 

a = 1;

 

b = 2;

 

c = (a+b);

 

disp(c);

After type your codes click the Run tool, than the code will be simulate and its output will be showing on command window. See below the output screenshot.

 

2

 

Here I use clc for clear command window, and use clear all for clear all variable memory. Then I use variable a for store 1 and use variable b for store 2 and use variable c for store a+b. After I use function disp() for show output of the c, that mean a+b.

*** Type the following codes for use arithmetic operator (-):

clc;

clear all;

a = 1;

b = 2;

c = (b-a);

disp(c);

After type your codes click the Run tool, than the code will be simulate and its output will be showing on command window. See below the output screenshot.

 

3

 

Here I use same method of previews code. I just change here the arithmetic operator + to -. And (b-a). That mean I want to do subtract between b and a.

*** Type the following codes for use arithmetic operator (*):

clc;

clear all;

a = 6;

b = 2;

c = (b*a);

disp(c);

After type your codes click the Run tool, than the code will be simulate and its output will be showing on command window. See below the output screenshot.

 

4

 

Here I also use same method of previews code. I just change here the arithmetic operator – to *, variable’s a value 1 to 6 and (b*a). That mean I want to do multiply between ‘b’ and ‘a’ or ‘a’ and ‘b’.

 

*** Type the following codes for use arithmetic operator (/):

clc;

clear all;

a = 6;

b = 2;

c = (a/b);

disp(c);

After type your codes click the Run tool, than the code will be simulate and its output will be showing on command window. See below the output screenshot.

 

5

 

Now I hope you are able to understood the above code for use arithmetic operator ‘/’. If you understood the code for ‘+’, ‘-‘ and ‘*’ arithmetic operator so you may understood it.

Now please try with arithmetic operator ‘’ by typing codes yourself.

Write Your Comments

comments

Leave a Reply