How can I extract specific rows from a data table?
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
dpb
il 28 Ago 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... :)
Risposta accettata
Chunru
il 28 Ago 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 Commenti
Chunru
il 28 Ago 2021
Very often, the table, array and matrix are misused in question. We have to guess what the questioner asks.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!