Undefined function 'times' for input arguments of type 'cell'.

5 ビュー (過去 30 日間)
sarah
sarah 2015 年 6 月 4 日
編集済み: sarah 2015 年 6 月 4 日
Hi Guys,
I have this error when i use fsolve to solve my equation which uses arrays from the two tables I have defined. The table data are doubles and however I thought it could solve it but it keeps giving me an error saying: "Undefined function 'times' for input arguments of type 'cell'". I have defined two tables called S and R which have 1 column each i.e. column matrix. Would anyone know why fsolve doesn't solve it? I have tried debugging and it gets stuck when i define myfun i.e function to solve. It worked normally before just not in the GUI.
Any help would be extremely appreciated.

採用された回答

Walter Roberson
Walter Roberson 2015 年 6 月 4 日
When you get() the Data from a uitable, the result is a cell array. If you want to convert the cell to a numeric matrix, use cell2mat(). For example,
X = cell2mat( get(handles.S, 'Data') );
One thing to watch out for is that it is not uncommon for the Data value of a uitable to be set to a cell array of strings, as using a cell array of strings allows you to control the exact format of the output display. If that has been done, if you are working with a cell array of strings that represent numbers, then you can use
X = str2double(get(handles.S, 'Data'));
with no cell2mat() needed. Note that any string not representable as a single number would be converted as NaN
  1 件のコメント
sarah
sarah 2015 年 6 月 4 日
Thank you so much. I wanted to ask you another thing.
I'm trying to fsolve my equation. In GUI it gives me a complex and completelty wrong answer whereas if I try the same thing in normal command window it gives me good answer. I'm unsure why that is? I checked all my variables are doubles but fsolve gives b equal to complex for some reason

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

その他の回答 (1 件)

Greig
Greig 2015 年 6 月 4 日
The most likely problem is that X and/or Y are cells. If so, then you will want to have a look are cell2mat to fix this.

カテゴリ

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