Converting Cell to Double

12 ビュー (過去 30 日間)
Alex Herron
Alex Herron 2019 年 6 月 17 日
コメント済み: Jan 2019 年 6 月 17 日
Hey all, I'm having some difficulting converting a 34529x1 cell into a double. I've been able to do this just fine with other cells, but seem to be struggling with this particular cell.
I've tried using cell2mat but just end up with this error:
pt_error.PNG
I also tried converting to a char, then to a double from there using str2double, however than just returns NaN. What's the best way to go about this?
The data looks like this:
potential_temperature_example.PNG
  4 件のコメント
Alex Herron
Alex Herron 2019 年 6 月 17 日
Update: this worked for me (a is the cell I'm working with)how_to_convert_pt.PNG
Jan
Jan 2019 年 6 月 17 日
"The data looks like..." is not useful. Prefer to post the data itself or explain, which type the data have. It looks like the cell elements are doubles, but then str2double would fail.
Defining m as a double matrix at first is pure magic. It does not have any effect but wasting time, because m is simply overwritten afterwards.
The cat command fails, because some of the cell elements do have different sizes.
So please post the actual values or test the sizes of teh cell elements by your own:
find(cellfun('size', a, 2) ~= 1)

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by