You are on page 1of 7

MATLAB BASICS

Introduction
• MATLAB is acronym for Matrix Laboratory
• MATLAB stores all variables in the form of a
matrix !!
• Every sentence should be followed by a semi-
colon
• MATLAB is used in areas of mathematics ,
engineering , economics etc
Mathematical operations
• ADDITION: C=A+B
• SUBTRACTION: C=A-B
• MULTIPLICATION: 1) C=A*B
• 2) C=A.*B
• DIVISION:C=A/B
• POWER:C=A.^2
Special functions
• All zero matrix: Zeros(1,N)
• All one matrix: Ones(1,N)
• Identity matrix: Eye(N)

Where ‘N’ is an positive integer


Condition statements
• if (condition)
……statements…..
elseif(condition)
…..statements….
else
….statement…
end;
Looping
1)while(condition)
….statements…..
…………
end;
2)for start: step size: end
………statements…..
end;
Plotting commands
• plot(X,Y)
• subplot(abc) or subplot(a,b,c)
• Eg: subplot(121)
• xlabel (‘ label ur x axes’)
• ylabel(‘label ur y axes’)
• title(‘write ur title of the figure here’)
• figure(n)-number your figure

You might also like