How can I extract specific rows from a data table?
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Naif Nawaf
am 27 Aug. 2021
Bearbeitet: Naif Nawaf
am 28 Aug. 2021
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 Kommentare
dpb
am 28 Aug. 2021
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... :)
Akzeptierte Antwort
Chunru
am 28 Aug. 2021
% 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 Kommentare
Chunru
am 28 Aug. 2021
Very often, the table, array and matrix are misused in question. We have to guess what the questioner asks.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!