Find NaN in a cell array and only delete the NaNs

11 vues (au cours des 30 derniers jours)
MatlabUser17
MatlabUser17 le 11 Avr 2019
How can I delete NaN s from a cell array (only the NaN elements not the whole column or row)?

Réponse acceptée

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

Plus de réponses (2)

madhan ravi
madhan ravi le 11 Avr 2019
C(cellfun(@(x)any(isnan(x)),C))=[]
  2 commentaires
madhan ravi
madhan ravi le 11 Avr 2019
Matrices cannot have holes.
MatlabUser17
MatlabUser17 le 11 Avr 2019
Modifié(e) : MatlabUser17 le 11 Avr 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.

Connectez-vous pour commenter.


Pruthvi G
Pruthvi G le 12 Mar 2020
Data(cellfun(@(cell) any(isnan(cell(:))),Data))={''};

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by