Find NaN in a cell array and only delete the NaNs

26 ビュー (過去 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 Center および File ExchangeStructures についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by