Find NaN in a cell array and only delete the NaNs

32 Ansichten (letzte 30 Tage)
MatlabUser17
MatlabUser17 am 11 Apr. 2019
Beantwortet: Pruthvi G am 12 Mär. 2020
How can I delete NaN s from a cell array (only the NaN elements not the whole column or row)?

Akzeptierte Antwort

Matt J
Matt J am 11 Apr. 2019
results(j)= sqrt( mean(array{j}.^2,'omitnan') );

Weitere Antworten (2)

madhan ravi
madhan ravi am 11 Apr. 2019
C(cellfun(@(x)any(isnan(x)),C))=[]
  2 Kommentare
madhan ravi
madhan ravi am 11 Apr. 2019
Matrices cannot have holes.
MatlabUser17
MatlabUser17 am 11 Apr. 2019
Bearbeitet: MatlabUser17 am 11 Apr. 2019
This deletes everything within a cell. Let me be more clear, let's assume:
matrix=[1,1,3,5;2,NaN,2,2;4,4,4,NaN]
[Mx My]=size(matrix)
for j=1:My;
array{j}=matrix(:,j);
% % array(cellfun(@(x)any(isnan(x)),array))=[]
results(j)=rms(array{j})
end
I want to calculate the RMS within each individual cell without considering NaN in each cell.

Melden Sie sich an, um zu kommentieren.


Pruthvi G
Pruthvi G am 12 Mär. 2020
Data(cellfun(@(cell) any(isnan(cell(:))),Data))={''};

Kategorien

Mehr zu Structures 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!

Translated by