|
Hi,
I'm trying to get a matrix that includes the coordinates that are in a sphere. These coordinates are chosen random. This is the script now:
R=2
N=10
c=(4*rand(3,N))-2
for i=1:N
A(i)=sum((c(:,i)).^(2));
if A(i)>R^(2)
c(:,i)=[];
end
end
The idea is that i create a 3 by N matrix with coordinates that are in a 4x4 box with. When the coordinates are squared and added they should not be bigger than 2^2=4. When it is bigger than 4 the column should be erased out of the random matrix c.
But it doesn't work. Does anybody know how I have to do this
|