conditional selection on table
28 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want the conditional selecton of a row in a table
- where name is ali
- where name is ali and age is between 25 to 30
- where name is ahmed, I want to multply his age with 2
kindly please help
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/332192/image.png)
0 Kommentare
Antworten (1)
KSSV
am 15 Jul. 2020
Bearbeitet: KSSV
am 15 Jul. 2020
You can access the columns of the table using T.columnname or T.(1), T.(2) etc...
To get the index where name 'Ali' lies, you can use
idx = strcmp(T.name,'Ali') ; % assuming name column to carry names
idx = strcmp(T.(1),'Ali') ; % assuming first column to be names
To get the ages indices.
id = T(idx).age>= 25 & T(idx).age <= 30 ; % assuming age is the column whihc has ages
Siehe auch
Kategorien
Mehr zu Matrices and Arrays 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!