How can I extract values from an N x 2 matrix?

1 回表示 (過去 30 日間)
RevengeOfTee
RevengeOfTee 2020 年 1 月 20 日
回答済み: Stijn Haenen 2020 年 1 月 20 日
So I have a user inputting N amount of values into a N x 2 matrix. Like so:
xx = input('Enter x coordinates in the form [0 0]');
yy = input('Enter y coordinates in the form [0 0]');
xp1 = xx';
yp1 = yy';
Cord = [xp1,yp1]
Now, what I want to do is extract each of the x-y coordinates in Cord to create points such as P4 = [cord(4,1),cord(4,2)]. The problem is, since the user is inputting the number of rows, I'm going to have N points and I can't figure out how to make a for loop that can account for all the points that will be created. It's been awhile.
Thank you!

回答 (1 件)

Stijn Haenen
Stijn Haenen 2020 年 1 月 20 日
What about this?:
cord=zeros(1,2);
for i=1:100
xx = input('Enter x coordinates in the form [0]');
yy = input('Enter y coordinates in the form [0]');
Cord(i,:) = [xx,yy];
end

カテゴリ

Help Center および File ExchangeCoordinate Transformations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by