Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
sphere coordinates

Subject: sphere coordinates

From: Jart

Date: 10 Jun, 2012 20:14:07

Message: 1 of 1

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

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us