Archive for the ‘Code Snippets’ Category
Progress Bar in Matlab
Link.
Matlab “parfor”
matlabpool open
parfor _____
_____
end
matlabpool close
…..
Check it out! See help parfor for details.
Angle of 2D Vector
Trivial, but convenient, this Matlab function gives the angle of a vector in 2D:
function a = ang(x,y)
n = sqrt(x^2+y^2);
if n == 0
a = 0;
else
c = x/n;
if y >= 0
a = acos(c);
else
a = 2*pi-acos(c);
end
end
end