The code currently generates a random scatter of 30 points. An array of x and y values are saved separately in x1 and y1.
I want to make multiple sets of x and y coordinates, so I can have multiple different arrays. For example if I wanted three different random scatters, the code would generate the arrays x1, y1, x2, y2, x3, y3, or if I wanted ten, then there would be ten x y pairings. And each pairing would generate a random scatter of points.
If anyone would be able to advise me, that would be great! I tried making a second for loop, but I couldn't figure out how to make it work… Here's the code I have written so far:
n = 30; %number of elements
R = 0.3; %maximum radius
x1 = zeros(n,1);y1 = zeros(n,1);for i = 1:1:n x1(i) = unifrnd(-R,R); y1(i) = unifrnd(-R,R);endfigure(1)plot(x1,y1, '.')%save('optArray','x1','y1')
Thanks in advance for your help!
Best Answer