フィルターのクリア

remove [NaN] from cell array

9 ビュー (過去 30 日間)
Michiel
Michiel 2015 年 4 月 14 日
コメント済み: Michiel 2015 年 4 月 16 日
I have large cell arrays in which a couple of entries could not be read from an excel file, since the corresponding places are empty. In my cell array I obtain: [NaN]
now I wish to replace this with an empty string: ''
this is what I tried and got:
>> raw(cellfun(@isnan,raw)) = {''};
Error using cellfun
Non-scalar in Uniform output, at index 1, output 1.
Set 'UniformOutput' to false.
>> raw(cellfun(@isnan,raw,'UniformOutput',false)) = {''};
Error using subsindex
Function 'subsindex' is not defined for values of class 'cell'.
suggestions?
  1 件のコメント
Jan
Jan 2015 年 4 月 16 日
Please post a relevant part of the cell raw such that we can reproduce the problem.

サインインしてコメントする。

採用された回答

Titus Edelhofer
Titus Edelhofer 2015 年 4 月 16 日
Hi,
if your raw contains both strings and NaN, you will need to do something like this:
raw(cellfun(@(x) isnumeric(x) && isnan(x), raw)) = {''};
If your raw contains numbers only, I would convert to an array (cell2mat) and then use isnan directly.
Titus
  1 件のコメント
Michiel
Michiel 2015 年 4 月 16 日
thank you, the first is what I was looking for

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by