Deleting an entire column using an IF statement

1 visualización (últimos 30 días)
Jake Bowd
Jake Bowd el 15 de Jun. de 2020
Editada: madhan ravi el 15 de Jun. de 2020
Hi,
I have a 91 x 265 double for which sometimes the first column contains NaN values. If the first column contains NaN values I would like to delete it. If the first column does not inlcude NaN I wish to keep that as the first column.
data = RESULTS.IK_Original(1).data;
NaN 0.308000000000000 0.0290000000000000 -0.790000000000000 0.993000000000000
NaN 0.317000000000000 0.0280000000000000 -0.779000000000000 0.991000000000000
NaN 0.325000000000000 0.0270000000000000 -0.768000000000000 0.990000000000000
NaN 0.333000000000000 0.0260000000000000 -0.758000000000000 0.989000000000000
NaN 0.342000000000000 0.0250000000000000 -0.747000000000000 0.989000000000000
NaN 0.350000000000000 0.0240000000000000 -0.736000000000000 0.988000000000000
NaN 0.358000000000000 0.0230000000000000 -0.725000000000000 0.988000000000000
NaN 0.367000000000000 0.0220000000000000 -0.714000000000000 0.987000000000000
NaN 0.375000000000000 0.0200000000000000 -0.703000000000000 0.988000000000000
Note: this is just the first 9 rows and 5 columns of my data.
Many thanks,

Respuesta aceptada

madhan ravi
madhan ravi el 15 de Jun. de 2020
Editada: madhan ravi el 15 de Jun. de 2020
data(:,all(isnan(data))) = [] % deletes entire column

Más respuestas (0)

Categorías

Más información sobre NaNs en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by