Você está na página 1de 4

Type casting:

A=char(A)
B=uint16(14)
*matlab by default consider every variable as double.
Declare Vector:
A = [1 2 3] *separate values with space between them
Declare Matrix:
A=[1,2,3; 4,5,6] *put semicolon between the rows

Super Matrix:
E={a,b;c,d} *E is a super matrix which contains other matrices a,b,c,d
Field Structure:
s.name=Anklon
s.ID=1106137
s(2).name=ashik
s(2).ID=1106140
*this hold the values as structure but in a matrix systemic way.
We can access these data as its in matrix like s(1,2) indicate second data
and s(1,2).name indicate second name.
Symbles & Operation:
matrix multiplication *
matrix addition +
but if one element is constant then MATLAB will multiply/add every element of the matrix with
that constant.

Piecewise multiplication between a and b a.*b
* adding a dot ( . ) before any operator like addition or multiplication indicate that MTALAB
will do the operation piecewise or element to element.
matrix transpose
not equal ~=

vector dot product: to do vector dot product first we have to transpose one vector
then do its matrix multiplication. Like e*f where e and f are vectors.

####
switch a(3,3)
case __
case __
otherwise
end


Functions:
zeros(a,b,c) create matrix with initial value zero
ones(a,b,c) create matrix with initial values one
rand(a,b,c) create matrix with initial random values
randint(a,b,c) create matrix with initial random integer values
*a,b,c indicate axbxc type matrix. Number of variable
indicate number of dimension.
Randn() random number containg negetive values also.
eye() create identity function.

strcat(a,b)=add two string a,b and assigned it to new one.
inv()= inverse matrix *must be square matrix.
mean() = give the mean of all data within.

PLOT:
plot(a,b,color code) plot 2D graph *color code part not mandatory
plot3(a,b,c) plot a 3D graph
plot(x,y1,x,y2,) plotting many graph in one page
subplot(2,side_number,row_number),plot() plotting grpah in seppareted
subwindows
bar() draw bargraph
grid adding grid in the bar graph
xlabel()
ylabel()
zlabel()
Gives the label of the axis of graph
title() title of the graph
legend() add legend in the graph

ploynomial solution:
polyval(p,x) return the correspondin values for every element of x due to the
polinomial p
polyfit(x,y,n) return a polinomial which contains coefficient for n power equatin
corresponding to x(i) for y(i)



Comments:
% comments after the statement
%{ between these everything is comment and may contains new
lines %}
... inline comment. Start with three dot and end with three dot. Generally
used to commented out statement.
Help comment: if an comment is written starting with % then it will be a help
comment. If we write help name in command windows.

Você também pode gostar