フィルターのクリア

I am not sure what the following error message indicates or how to resolve it: 'Error using double Conversion to double from cell is not possible.'

1 回表示 (過去 30 日間)
How might I address this error?
Error using double Conversion to double from cell is not possible.
The associated line of code is simply: (mat1)=double(mat2);

採用された回答

Wayne King
Wayne King 2012 年 10 月 23 日
編集済み: Wayne King 2012 年 10 月 23 日
It means that mat2 is a cell array and you cannot immediately cast it to a double. Depending on the contents of mat2, perhaps you can use cell2mat
x = cell(2,1);
x{1} = randn(10,1,'single');
x{2} = randn(10,1,'single');
% double(x) this throws the error you report
y = double(cell2mat(x)); % this does not
But you should show us a simple model of what your cell array looks like.

その他の回答 (1 件)

Jan
Jan 2012 年 10 月 23 日
編集済み: Jan 2012 年 10 月 23 日
Please take the time to read the error message again:
Conversion to double from cell is not possible.
This means, it is hard to express it in other words, that your code tries to convert a cell to a double, and this is not possible. Matlab's error messages are the best I've ever seen.
But as Wayne has explained already, you can convert the elements of a cell to a double array.
  1 件のコメント
Matt Fig
Matt Fig 2012 年 10 月 23 日
It is hard to express it in other words and maybe impossible to express it in better words...

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

カテゴリ

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