Find NaN in a cell array and only delete the NaNs

33 visualizaciones (últimos 30 días)
MatlabUser17
MatlabUser17 el 11 de Abr. de 2019
Respondida: Pruthvi G el 12 de Mzo. de 2020
How can I delete NaN s from a cell array (only the NaN elements not the whole column or row)?

Respuesta aceptada

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

Más respuestas (2)

madhan ravi
madhan ravi el 11 de Abr. de 2019
C(cellfun(@(x)any(isnan(x)),C))=[]
  2 comentarios
madhan ravi
madhan ravi el 11 de Abr. de 2019
Matrices cannot have holes.
MatlabUser17
MatlabUser17 el 11 de Abr. de 2019
Editada: MatlabUser17 el 11 de Abr. de 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.

Iniciar sesión para comentar.


Pruthvi G
Pruthvi G el 12 de Mzo. de 2020
Data(cellfun(@(cell) any(isnan(cell(:))),Data))={''};

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by