Removing NAN values from the table and deleting it.

조회 수: 45 (최근 30일)
Shelender Kumar
Shelender Kumar 2018년 11월 17일
편집: Voss 2025년 2월 12일
Hi
I have a table which is arrranged in susch a waym that it has one row of data and other row which contain NAN and so on, I want to get rid of NAN and aferwards deleting it.
Could you help me with this.

채택된 답변

madhan ravi
madhan ravi 2018년 11월 17일
편집: madhan ravi 2018년 11월 17일
rmmissing(T) %deletes row containing nan where T your table
  댓글 수: 16
madhan ravi
madhan ravi 2018년 11월 19일
Thank you sir Walter , have to familiarise with any and all it‘s slightly confusing :)
Talha Idrees
Talha Idrees 2021년 5월 2일
not works

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

추가 답변 (2개)

ahmed nebli
ahmed nebli 2018년 11월 17일
use this : (isnan(X)) = [] % X is the table
  댓글 수: 5
Talha Idrees
Talha Idrees 2021년 5월 2일
not works
Walter Roberson
Walter Roberson 2021년 5월 3일
not works
Magik 8-Ball says:
Concentrate and ask again

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


Francesco
Francesco 2025년 2월 12일
편집: Francesco 2025년 2월 12일
Following another question I found this code working really good:
Xnew=X((isfinite(X)));
The new array has no Nan inside.
  댓글 수: 5
Francesco
Francesco 2025년 2월 12일
편집: Francesco 2025년 2월 12일
Yes the principle is the same, if you have a table, for example in your case, you can call the columns using T.Column_name, in this case:
T = array2table([1,2,3;nan,2,3;1,2,3;1,2,3;nan,2,3])
T = 5x3 table
Var1 Var2 Var3 ____ ____ ____ 1 2 3 NaN 2 3 1 2 3 1 2 3 NaN 2 3
X=T.Var1 ; Y=T.Var2; Z=T.Var3;
Xnew=X((isfinite(X)));
Ynew=Y((isfinite(X)));
Znew=Z((isfinite(X)));
T_new = array2table([Xnew,Ynew,Znew])
T_new = 3x3 table
Var1 Var2 Var3 ____ ____ ____ 1 2 3 1 2 3 1 2 3
Voss
Voss 2025년 2월 12일
편집: Voss 2025년 2월 12일
T = array2table([1,2,3;nan,2,3;1,2,3;1,2,3;nan,2,3])
T = 5x3 table
Var1 Var2 Var3 ____ ____ ____ 1 2 3 NaN 2 3 1 2 3 1 2 3 NaN 2 3
T_new = T(isfinite(T.Var1),:)
T_new = 3x3 table
Var1 Var2 Var3 ____ ____ ____ 1 2 3 1 2 3 1 2 3
Since the question only asked about NaNs, isnan might be a better function to use than isfinite, i.e.
T_new = T(~isnan(T.Var1),:)
T_new = 3x3 table
Var1 Var2 Var3 ____ ____ ____ 1 2 3 1 2 3 1 2 3

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by