Delete rows in a table where data in one column is below a value

조회 수: 2 (최근 30일)
DavidL88
DavidL88 2021년 1월 20일
댓글: DavidL88 2021년 1월 20일
Hi
I have a table with four columns and multiple rows of data. I want to delet all rows where the value of teh data in the 4th columns is less than 0.1. Can anyone advise how to do this?
I tried this code to keep those rows where the data was >=0.1 but got the below message. Tis the table with all the data and Tmain is the new inteneded table without the those rows where data is <0.1 in 4th column.
T = table(T4, T1, T2, T3)
Tmain = T(T(:,4)>=0.1,:)
Operator '>=' is not supported for operands of type 'table'.
Error in working_file_2 (line 31)
Tmain = T(T(:,4)>=0.1,:)

채택된 답변

Adam Danz
Adam Danz 2021년 1월 20일
> I want to delet all rows where the value of the data in the 4th columns is less than 0.1.
T(T{:,4}<0.1,:) = [];
  댓글 수: 3
Adam Danz
Adam Danz 2021년 1월 20일
편집: Adam Danz 2021년 1월 20일
You can't use the equal sign twice as in A=B=C.
Instead you've got two options. The second is more efficient.
1
Tmain = T;
Tmain(Tmain{:,4}<0.1,:) = [];
2
Tmain = T(T{:,4}>=0.1,:)
% ^^ Note difference
DavidL88
DavidL88 2021년 1월 20일
Worked a charm thanks

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

추가 답변 (0개)

카테고리

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