Average a cell with ignoring NaN
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
I want to average with ignoring the NaN. I used the script below:
Intens2 = cellfun(@(C) cellfun(@mean, C), new_table3.extData, 'uniform', 0)
and the and I do average to Intens2
Intens3=cellfun(@mean, Intens2);
Is there a way to average in Intens2 and Intens2 with ignoring NaN?
where I can put 'omitnan'?
Thank you very much,
1 Kommentar
Akzeptierte Antwort
Jan
am 29 Apr. 2021
C = {[1,2,4,6,NaN], [NaN, 2, 3, NaN]};
MC = cellfun(@(x) mean(x, 'omitnan'), C)
2 Kommentare
Jan
am 30 Apr. 2021
You are welcome. There are 3 nested cellfun calls in your code. Usually loops are faster than the nice cellfun. I'd post a loop method, if it is clear, what exactly your inputs are.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!