Find specific entry based on column value in table

2 vues (au cours des 30 derniers jours)
NFC
NFC le 30 Avr 2021
Commenté : Cris LaPierre le 30 Avr 2021
Apologies if this has been asnwered somewhere but I was unable to find a simple answer to what I strongly suspect is a really simple operation in MATLAB. I have a simple table (see attached), and I want to extract the number that corresponds to the name 'Bob'. (so in this case, 2). How would I extract this? Essentially I am looking for the row index of a table where the column value is something specific.
Thanks,

Réponse acceptée

Cris LaPierre
Cris LaPierre le 30 Avr 2021
I'd create a logical array of the name column, and use that to extract the number from the first column. You can learn about logical arrays in Ch 12 of MATLAB Onramp. This page on accessing data in a table is likely also helpful.
The code might be something like this
n = data.Number(data.Name=='Bob')
  4 commentaires
NFC
NFC le 30 Avr 2021
Modifié(e) : NFC le 30 Avr 2021
I am actually not doing the loading myself, I'm reading it off a dicomfile as shown on the mathworks website
dicominfo(path)
and then accessing contours with
contours=dicomContours(info);
and finally loading the table with
ROIs=contours.ROIs;
Cris LaPierre
Cris LaPierre le 30 Avr 2021
I missed that detail. I think I like the strcmp approach better anyway.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by