Removing NAN values from the table and deleting it.

96 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

madhan ravi
madhan ravi il 17 Nov 2018
Modificato: madhan ravi il 17 Nov 2018
rmmissing(T) %deletes row containing nan where T your table
  16 Commenti
madhan ravi
madhan ravi il 19 Nov 2018
Thank you sir Walter , have to familiarise with any and all it‘s slightly confusing :)

Accedi per commentare.

Più risposte (2)

ahmed nebli
ahmed nebli il 17 Nov 2018
use this : (isnan(X)) = [] % X is the table
  5 Commenti
Walter Roberson
Walter Roberson il 3 Mag 2021
not works
Magik 8-Ball says:
Concentrate and ask again

Accedi per commentare.


Francesco
Francesco il 12 Feb 2025 alle 13:56
Modificato: Francesco il 12 Feb 2025 alle 13:56
Following another question I found this code working really good:
Xnew=X((isfinite(X)));
The new array has no Nan inside.
  5 Commenti
Francesco
Francesco il 12 Feb 2025 alle 19:10
Modificato: Francesco il 12 Feb 2025 alle 19: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 il 12 Feb 2025 alle 19:43
Modificato: Voss il 12 Feb 2025 alle 19:47
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

Accedi per commentare.

Categorie

Scopri di più su Tables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by