Divide points according to quadrant system
古いコメントを表示
I have written a code to divide L pairs (coordinates) according to 4 quadrants:
L=input('Enter the number of pairs: ');
tr=randi(10,L,2);
xy=sortrows(tr);
a=1;
b=1;
c=1;
d=1;
for ii=1:10
if xy(ii,1)<=5 && xy(ii,2)<=5
xy1(a,:)=xy(ii,:);
a=a+1;
elseif xy(ii,1)>5 && xy(ii,1)<11 && xy(ii,2)<=5
xy2(b,:)=xy(ii,:);
b=b+1;
elseif xy(ii,1)>5 && xy(ii,1)<11 && xy(ii,2)>5 && xy(ii,2)<11
xy3(c,:)=xy(ii,:);
c=c+1;
elseif xy(ii,1)<=5 && xy(ii,2)>5 && xy(ii,2)<11
xy4(d,:)=xy(ii,:);
d=d+1;
end
end
There is a main array xy(Lx2) which takes random integer pairs and then divides them into 4 more additional arrays: xy1, xy2, xy3, xy4. The 2 dividing lines are x=5 and y=5. Starting from bottom-left and going in anticlockwise direction to top left.
2 件のコメント
Rik
2018 年 6 月 17 日
What is exactly your question? Would you like to know how to un-loop this? Or how to make it more adaptable to different division lines?
Vatsal Gupta
2018 年 6 月 18 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Import and Analysis についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
