Find NaN in a cell array and only delete the NaNs

조회 수: 11 (최근 30일)
MatlabUser17
MatlabUser17 2019년 4월 11일
답변: Pruthvi G 2020년 3월 12일
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
madhan ravi
madhan ravi 2019년 4월 11일
Matrices cannot have holes.
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