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!