필터 지우기
필터 지우기

Find Index of Table data satisfying some condition

조회 수: 31 (최근 30일)
Nikita Agrawal
Nikita Agrawal 2020년 4월 22일
댓글: Deepak Gupta 2020년 4월 22일
I have a table in which I want to do conditional formatting dependoing upon conditions certain values in different column follow.

답변 (1개)

Deepak Gupta
Deepak Gupta 2020년 4월 22일
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
Nikita Agrawal
Nikita Agrawal 2020년 4월 22일
yes, but I want it for all the elements of the table,
T(T(2:end,2:end)<150)=0
Deepak Gupta
Deepak Gupta 2020년 4월 22일
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);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by