필터 지우기
필터 지우기

Convert array of cells to array of doubles

조회 수: 1 (최근 30일)
Erik de Boer
Erik de Boer 2014년 12월 7일
댓글: Star Strider 2014년 12월 7일
Hello,
I'm trying to convert an array of cells to an array of doubles. However the cell array is shaped a bit unfortunate, with unnecessary nesting:
northing_raw 51x1 cell
northing_raw{1,1} 1x1 cell
northing_raw{1,1}{1,1} 1x9 char
e.g.:
northing_raw{1,1}{1,1} = 5923991.9
Is there a way to avoid loops when I want to create a double array?
Best, Erik

채택된 답변

Star Strider
Star Strider 2014년 12월 7일
I cannot say if the nesting is unnecessary, but since cells by definition can contain variables of different types and sizes, you would likely have to create each double array separately.
However, if you have several different matrices of the same sizes and data types, you can concatenate them into a single array, but that’s the best you can hope for.
You will likely also have to loop through them.
  댓글 수: 2
Erik de Boer
Erik de Boer 2014년 12월 7일
Thanks SS, that put me on the right track. I just had to concatenate them.
northing_raw = [northing_raw{:}];
Northing = cellfun(@str2num,northing_raw);
Star Strider
Star Strider 2014년 12월 7일
My pleasure!

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by