Fixing my counter statement.
Afficher commentaires plus anciens
So I have two arrays (x and y) that are 324 long columns. I need to separate the each pair(x,y) of points into what quadrant the point falls into when graphed. For example if the first x and y are (-3,4) I need to put that point into an array of the other points in the data that fall in quadrant two. What am I doing wrong?
Q=[x y];
for counter=1:length(Q)
if x(counter)>0 && y(counter)>0
Q1=[x(x>0) y(y>0)'];
end
if x(counter)<0 && y(counter)>0
Q2=[x(x<0) y(y>0)'];
end
if x(counter)<0 && y(counter1)<0
Q3=[x(x<0) y(y<0)'];
end
if x(counter)>0 && y(counter1)<0
Q4=[x(x>0) y(y<0)'];
end
end
Réponse acceptée
Plus de réponses (1)
John D'Errico
le 1 Mai 2015
Why all the tests?
whichQuadrant = @(x,y) 1 + floor(mod(atan2d(y,x)/90,4));
Catégories
En savoir plus sur Operators and Elementary Operations dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!