MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

Elaheh
0

deleting NaNs in a column without changing the size of the matrix

Elaheh
さんによって質問されました 2019 年 1 月 20 日
最新アクティビティ Image Analyst
さんによって 回答されました 2019 年 1 月 20 日
Hi
I used this script to delete a few NaN s I have in column 5 of a file, However, the size of the matrix changed too. How should I change the edit the script to keep the size of the matrix the same?
Than you
dataEEG(isnan(dataEEG(:,5)),:) = [];

  3 件のコメント

"How should I change the edit the script to keep the size of the matrix the same?"
In general you can't: matrices cannot have "holes" in them.
Rik
2019 年 1 月 20 日
Even sparse matrices have a value at the positions that aren't filled. The only data type that can have empty elements is the cell:
C={1,[],3;4,5,6}
"The only data type that can have empty elements is the cell:"
Although that cell itself is not empty, only the array inside that cell. A cell array cannot have holes in it either: every cell is a scalar cell (regardless of what it contains).

サインイン to comment.

タグ

1 件の回答

回答者: Image Analyst
2019 年 1 月 20 日
 採用された回答

No you can't. If you delete the rows, the matrix will shrink. What you can do is to either set the nan elements to some known, constant value, or to fill in the nan regions with data from surrounding regions with something like regionfill() or a modified median filter. Would you like to do that? With regionfill() there is no max region size to fill in, but for a modified median filter you'd have to know the largest size of nan region in advance, which you can find.

  0 件のコメント

サインイン to comment.



Translated by