フィルターのクリア

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 Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by