Find NaN in a cell array and only delete the NaNs

35 次查看(过去 30 天)
How can I delete NaN s from a cell array (only the NaN elements not the whole column or row)?

采纳的回答

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

更多回答(2 个)

madhan ravi
madhan ravi 2019-4-11
C(cellfun(@(x)any(isnan(x)),C))=[]
  2 个评论
MatlabUser17
MatlabUser17 2019-4-11
编辑:MatlabUser17 2019-4-11
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.

请先登录,再进行评论。


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

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by