Skip to main content

My Matlab Notes

My Matlab notes: 

Clear Variables: 

clear all variables
 >> clear

 clear a variable
 >> clear x

Set zeros on a variable 
create zero on matrix 3 x 3
 >> x = zeros(3)

 create zero on matrix 1 x 3
 >> x = zeros(1,3)

 create zero on matrix 0 x 3
 >> x = zeros (0,3)

 set a certain number on a matrix column
>> x(:,2) = 5

Matrix concatenation 
Concat horizontal (sideway)
 >> a = [2 3]
 a =
 2 3

 >> b = [4 5]
 b =
 4 5

 >> c = [a,b]
 c =
 2 3 4 5

 Concat Vertical
 >> d = [a;b]
 d =
 2 3
 4 5

Display segment for two sequential points

for i=1:size(data,1)-1
    plot3([data(i,2) data(i+1,2)],[data(i,3) data(i+1,3)], [data(i,4) data(i+1,4)],'b-')
end

Comments

Popular posts from this blog