Loop through array containing coordinates points
2 ビュー (過去 30 日間)
古いコメントを表示
Hi, im trying to loop through an array containing coordinates in order to plot them and automatize this process, I've tried doing the following:
p0 = [1, 1];
p1 = [2, 3];
p2 = [4, 3];
p3 = [3, 1];
cords = [p0, p1, p2, p3];
for index = 1:length(cords)
pX = cords(index) % don't know how to take first value (1) not working
pY = cords(index) % same here
disp(pX)
disp(pY)
plot(pX,pY,.....)
end
I can't get something like this to work, I always end up getting just the first point instead of both of them.
I've also tried setting the points like
p0 = [1 1] %with spaces
But I don't know how to make it work. If you could help me I'd be very grateful, thanks
0 件のコメント
採用された回答
Arif Hoq
2022 年 2 月 8 日
Try this...
p0 = [1, 1];
p1 = [2, 3];
p2 = [4, 3];
p3 = [3, 1];
cords = [p0, p1, p2, p3];
N=length(cords);
for i = 1:length(cords)
pX{i} = cords(i); % don't know how to take first value (1) not working
pY{i} = cords(i); % same here
end
pX_value=[pX{:}];
pY_value=[pY{:}];
disp(pX_value)
disp(pY_value)
plot(length(pX_value),pX_value,'*')
ylim([0 5])
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
