Plotting scatter plot using X coordinate matrix and Y coordinate matrix
Mostrar comentarios más antiguos
Hello,
I have 2 matrices (18x76): one for x coordinate location and one for y coordinate location representing nodes.
I want to plot these nodes in a scatterplot using a for loop. I also want to have an if statement saying "if the x coordinate is greater than 15, don't plot a pixel there" and "if the y coordinate is greater than 3, don't plot a pixel there".
For example, matrix X(4,5) = 0.9 and matrixY(4,5) = 0.5196 so there should be a red circle on the graph at that location.
Here is the working code I have so far: Please let me know if this doesn't make sense. Any help would be appreciated!
for x_coor_col=1:76
for x_coor_row=1:18
for y_coor_col=1:76
for y_coor_row=1:18
if x_coor(x_coor_row,x_coor_col) > 15 | y_coor(y_coor_row,y_coor_col) > 3
%don't plot pixel
else
% plot a pixel at that location
end
end
end
end
end
3 comentarios
Jan
el 13 de Feb. de 2021
"there should be a red circle on the graph at that location" - at which location? [4,5] or [0.9, 0.5196]?
Radhika Kulkarni
el 13 de Feb. de 2021
KALYAN ACHARJYA
el 13 de Feb. de 2021
Is this ? DO Modify as per requiremnets. Still, I'm not clear about the question, so I've posted comments
x_coor=randi(20,[18,76]);
y_coor=randi(20,[18,76]);
mask=x_coor> 15 | y_coor > 3;
%Plot Data with red color
scatter(x_coor(mask),y_coor(mask),'ro','linewidth',2);
hold on;
% Donot Plot data with blue color
scatter(x_coor(~mask),y_coor(~mask),'b*','linewidth',2);
If you dont want 2nd one, just delete the last line.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Scatter Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!