Find Index of Table data satisfying some condition
Mostrar comentarios más antiguos
I have a table in which I want to do conditional formatting dependoing upon conditions certain values in different column follow.
Respuestas (1)
Deepak Gupta
el 22 de Abr. de 2020
0 votos
Hello Nikita,
You can use conditions as index of the table to do this. For example if you have a table Table1 and the condition is to find a value in table equal to 5 and then replace it with a different number;
Than,
Table1(Table1(:, :)==5) = 6;
will assign 6 to fields which were equal to 5 earlier.
Thanks,
Deepak
4 comentarios
Nikita Agrawal
el 22 de Abr. de 2020
Deepak Gupta
el 22 de Abr. de 2020
In real cases, i guess you are trying to compare one of the column of table with constant 150, if value less, then replace it with 0. Right? So lets you want to change values in column named FirstColumn. This can be achieved with
T(T.FirstColumn<150)=0;
Nikita Agrawal
el 22 de Abr. de 2020
Deepak Gupta
el 22 de Abr. de 2020
Then, i guess, it will be better to convert table into array.
Row1 = 200*rand(10, 1);
Row2 = 200*rand(10, 1);
Row3 = 200*rand(10, 1);
T = table(Row1, Row2, Row3);
arrayT = table2array(T);
arrayT(arrayT<150)=0;
T = array2table(arrayT);
Categorías
Más información sobre Tables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!