How can I extract specific rows from a data table?
15 ビュー (過去 30 日間)
古いコメントを表示
I have a large data table of xyz coordinates, and I want to extract only two specific rows and define the x, y, z for these rows to calculate the distance formula between these two points. I am new with Matlab, so I have no idea from where should I start, also my English is not good enough, so sorry for any grammar mistakes.
2 件のコメント
dpb
2021 年 8 月 28 日
Logical or direct indexing -- without some idea what rule you want to use to define the specific rows of interest, it's hard to know.
Look at a previous similar Q? <here> and see if that doesn't provide enough traction to get started...if not, describe precisely what your table structure is and what you want. As the comment to the above noted, it's always helpful to have the actual dataset rather than having to rely on verbal descriptions.
And, btw, your English is plenty good enough, your message was just a little short on details... :)
採用された回答
Chunru
2021 年 8 月 28 日
% some random xyz coordinates
xyz = randn(10, 3)
% specify two points
p1 = 2; % second point
p2 = 7; % 7th point
xyz(p1, :)
xyz(p2, :)
% compute the distance of two points
% p1 p2
d = sqrt(sum((xyz(p1, :)-xyz(p2, :)).^2))
3 件のコメント
Chunru
2021 年 8 月 28 日
Very often, the table, array and matrix are misused in question. We have to guess what the questioner asks.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!