Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

How to relate x and y coordinate matrices to points on a larger matrix of zeroes?

1 Ansicht (letzte 30 Tage)
Spencer Checkoway
Spencer Checkoway am 29 Jul. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
x=zeros(1000); %creates a 100x100 zeros matrix
numRandom = 10; % Generate 10 random locations...
xli = ceil(sqrt(numel(x)) * rand(1, numRandom));
yli = ceil(sqrt(numel(x)) * rand(1, numRandom));
i_theta_max =100;
for i_theta = 0:i_theta_max
theta = i_theta/(i_theta_max)*2*pi;
xcoord(i_theta+1)=1*sin(theta); % Added 1
ycoord(i_theta+1)=1*cos(theta); % Added 1
end
x_index= round(xli'+xcoord)';
y_index= round(yli'+ycoord)';
I have gotten two matrices xli and yli that are my random center point coordinates and the for loop is to try to get all of the points in a circle of radius 1 around those points. From there I rounded with the hope of later plotting them discretely by changing the color value of those points. I don't know how to get my x and y indices to to correspond to the larger x matrix of zeros so that those points and the points within that 'circle' can be changed to a color value. May have gone down the wrong path to get what I'm going for.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by