How to convert cell array with Nan to a double array with Nan=0?

9 次查看(过去 30 天)
I have imported data with NaN and other values all in one column. I need to convert this into a double array where all of NaNs are set to zero. Please help! Thanks!

回答(1 个)

Cedric
Cedric 2017-9-26
编辑:Cedric 2017-9-26
x = cell2mat(C) ;
x(isnan(x)) = 0 ;
  2 个评论
Alexandria Will-Cole
x = cell2mat(val) ;
x(isnan(x)) = 0 ;
I get this error message:
Error using cat Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 83) m{n} = cat(1,c{:,n});
Cedric
Cedric 2017-9-26
Then it's not all in one column I guess, but you have a cell array of vectors or a cell array of cell arrays. Can you copy/past part of the content?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by