Hi, I'm new in using Matlab.
X and Y is the centre point of my circle.
I want to store the value of x and y which will be random numbers. So i use the rand function.
I want to do this for N number of times, so how can i store ALL the values for x and y in an array, not just the LAST value of x and y?
This is important because i want to check if the distance between my latest centre of circle with the all of the previous ones in order to avoid overlapping of the circles.
Any suggestions?
|
|
0
|
|
|
|
Reply
|
mmm
|
11/8/2010 12:32:05 PM |
|
"mmm " <muzzeinmlk@yahoo.com> wrote in message
news:ib8qk5$aru$1@fred.mathworks.com...
> Hi, I'm new in using Matlab.
>
> X and Y is the centre point of my circle.
> I want to store the value of x and y which will be random numbers. So i
> use the rand function.
>
> I want to do this for N number of times, so how can i store ALL the values
> for x and y in an array, not just the LAST value of x and y?
>
> This is important because i want to check if the distance between my
> latest centre of circle with the all of the previous ones in order to
> avoid overlapping of the circles.
>
> Any suggestions?
Don't generate the points one-at-a-time. Generate all N centers at once.
N = 10;
xy = rand(N, 2);
If, for whatever reason, you MUST generate the centers one-at-a-time, don't
forget to preallocate.
N = 10;
xy = zeros(N, 2);
for whichcenter = 1:N
xy(whichcenter, :) = rand(1, 2);
% Do other work with xy(whichcenter, :)
end
--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
|
|
0
|
|
|
|
Reply
|
Steven_Lord
|
11/8/2010 2:17:30 PM
|
|