Deleting an entire column using an IF statement

1 次查看(过去 30 天)
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,

采纳的回答

madhan ravi
madhan ravi 2020-6-15
编辑:madhan ravi 2020-6-15
data(:,all(isnan(data))) = [] % deletes entire column

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 NaNs 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by