필터 지우기
필터 지우기

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

조회 수: 11 (최근 30일)
Alexandria Will-Cole
Alexandria Will-Cole 2017년 9월 26일
댓글: Cedric 2017년 9월 26일
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
Alexandria Will-Cole 2017년 9월 26일
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