Color for points in scatter plot based on quadrants
Afficher commentaires plus anciens
matrix=load('Data');
x = matrix(:,1);
y = matrix(:,2);
matrix(x>0 & y>0,3) = 1;
matrix(x<0 & y>0,3) = 2;
matrix(x<0 & y<0,3) = 3;
matrix(x>0 & y<0,3) = 4;
if x<-128 or x>128 or y<-128 or y>128
'Error:Value exceeds limit'
end
if matrix(:,3)==1 or matrix(:,3)==3
scatter(x,y,'.r')
elseif matrix(:,3)==2 or matrix(:,3)==4
scatter(x,y,'.b')
end
title('Variables and Their Quadrants')
xlabel('X Values')
ylabel('Y Values')
So here's my problem: what I need to do is have any points in quadrants 1 and 3 to be red and any points in quadrants 2 and 4 to be blue. I am using a third row to determine the quadrant, but when I plug that row into a if statement, the script pretends it does not exist. How do I fix this problem?
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!