How to get specified data in table

3 vues (au cours des 30 derniers jours)
Arif
Arif le 19 Fév 2024
Commenté : Arif le 21 Fév 2024
Please help me.
How can i filter the table by specified 'Pushover-x' as a rownames and only vartype 'StepNum' , 'GlobalFX', 'GlobalFZ' data which i want to get.

Réponse acceptée

Stephen23
Stephen23 le 19 Fév 2024
Modifié(e) : Stephen23 le 19 Fév 2024
Where T is your table:
idx = strcmpi(T.OutputCase,'Pushover-x');
out = T(idx,{'StepNum','GlobalFX','GlobalFZ'})
Note that if OutputCase really were the RowNames then you could have done this:
out = T('Pushover-x',{'StepNum','GlobalFX','GlobalFZ'})
  6 commentaires
Stephen23
Stephen23 le 21 Fév 2024
Modifié(e) : Stephen23 le 21 Fév 2024
"but it was error"
Then you need to tell us exactly what the error is. Show us all of the red text.
"so it cant take two filters in one variable ?"
MATLAB does not limit how many AND operators can be chained one after another.
But your logic using AND is most likely incorrect: can you show one single value of the OUTPUTCASE field whose value is both equal to "Pushover-X" and also to "MODAL" ? That is what AND means.
I am guessing that you intended to use OR:
idx = strcmp(T.Joint,'5') & (strcmp(T.OutputCase,'Pushover-x') | strcmp(T.OutputCase,'MODAL'));
or perhaps ISMEMBER or MATCHES or similar:
idx = strcmp(T.Joint,'5') & ismember(T.OutputCase,{'Pushover-x','MODAL'});
Arif
Arif le 21 Fév 2024
thanks stephen, ismember was the result

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by