Plotting scatter plot using X coordinate matrix and Y coordinate matrix
Afficher commentaires plus anciens
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 commentaires
Jan
le 13 Fév 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
le 13 Fév 2021
KALYAN ACHARJYA
le 13 Fév 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.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Scatter Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!