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!