필터 지우기
필터 지우기

Change data type of entire cell array?

조회 수: 20 (최근 30일)
Tyler Bodnarik
Tyler Bodnarik 2020년 11월 18일
댓글: Tyler Bodnarik 2020년 11월 18일
I have a 1 x 2500 cell array created from a .txt file. Each cell has one long string of many individual numbers that I need. EX: '1 2 3 4 5 6 7 8 9'
I need to make each number in the entire cell array a double value type. str2double doesn't work because I need to split up the string. I tried using strsplit but maybe I was doing it wrong.
Any advice?
  댓글 수: 1
Tyler Bodnarik
Tyler Bodnarik 2020년 11월 18일
newA = cellfun(@(x) strsplit(x), BM, 'UniformOutput', false);
With this I now have a cell array with each cell being it's own seperate cell array. However I need to get every value to be a double data type.
str2double(newA) outputs NaN

댓글을 달려면 로그인하십시오.

답변 (1개)

madhan ravi
madhan ravi 2020년 11월 18일
cellfun(@(x) sscanf(x, '%d').', Cell_array, 'un', 0)
  댓글 수: 1
Tyler Bodnarik
Tyler Bodnarik 2020년 11월 18일
I tried this out. It just outputted 1s and 0s.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by