Delete rows or column with NaN for a cell array

I really thanks in advance any help. How can I delete NaN's of column from the cell attached as example file here.
Thanks

 Akzeptierte Antwort

Bhaskar R
Bhaskar R am 17 Feb. 2020
nan_loc = cellfun(@(x)any(isnan(x)), P_QC, 'UniformOutput', false);
for ii=1:length(P_QC)
P_QC{ii}(:,nan_loc{ii}) = [];
end

4 Kommentare

Dear Bhaskar,
Thanks, but now by removing NaN I have to also remove the longitude corresponding to the NaN. Could you please tell me how can I do it. please find lon as attached you can compare with P_QC
Dear Bhaskar,
I thinks the following cod is working,
for ii=1:length(P_QC)
lon{ii}(nan_loc{ii}) = [];
end
Bhaskar R
Bhaskar R am 17 Feb. 2020
Yeah, same applicable for lon
Thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Pruthvi G
Pruthvi G am 12 Mär. 2020

0 Stimmen

Data(cellfun(@(cell) any(isnan(cell(:))),Data))={''};

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by