EEE 306 Lab 8 : Introduction to Matlab

September 20, 2017
By shp

This Lab is about an introduction to matlab.

The objective of this lab is to learn about

  • Basic mathematical and logical operator in matlab
  • Working with Matrix and vector
  • Use of conditional ‘if’
  • Use of for and while loop

Practice script

 %Basic matrix operation
 a=[1 2 3;4 5 6;7 8 9]
 b=[3 2 1;6 5 4;9 8 7]
 c=a+b
 d=a*b
 n=5
 e=a+n*c

%Use of if, while and for
%while 1 %Try not to use while 1 in matlab. It is not a good idea.
total=0
for i=0:1:5
mark= input('What is the mark ')

if mark >=90 
 point=5;
elseif mark>=80 
 point=4;
elseif mark>=70 
 point=3;
elseif mark>=60 
 point=2;
elseif mark>=50 
 point=1;
else
 point=0;
end % end of if
total=total+point;
end %end of for loop

total=total/6

%end % end for while loop

MATLAB intro

Leave a Reply