Undefined operator '-' for input arguments of type 'cell'.

1 回表示 (過去 30 日間)
tahseen alshmary
tahseen alshmary 2018 年 12 月 4 日
コメント済み: Guillaume 2018 年 12 月 5 日
dear all
i have this error
Undefined operator '-' for input arguments of type 'cell'.
Error in Untitled4 (line 90)
tolerance=abs(ffmin(ite-100,run)-fmin0);
the code is
% calculating tolerance
if ite>100;
tolerance=abs(ffmin(ite-100,run)-fmin0);
end

回答 (1 件)

Guillaume
Guillaume 2018 年 12 月 4 日
Your code expect ffmin to be a matrix. We can deduce from the error that it is not, it's a cell array. And indeed subtraction is not defined from a cell array (it's just a container).
So, either that line is wrong and should somehow be able to deal with a cell array, or something wrong happened before (perhaps you gave a cell array as input and your function didn't check that the input was invalid). Either way, with what little information you've given we can't tell you how to solve it.
Possibly,
tolerance=abs(ffmin{ite-100,run}-fmin0);
would fix it. But then the question becomes, why is a cell array used to store scalar numerics?
  2 件のコメント
tahseen alshmary
tahseen alshmary 2018 年 12 月 5 日
i do not know and all my result appear wrong
Guillaume
Guillaume 2018 年 12 月 5 日
Well, as I said, it's most likely that ffmin shouldn't be a cell array. So, you''ve got to find out why it is. Possibly, there's a bug earlier in your code that makes it a cell array. Possibly, you've passed the wrong input to the program. Possibly, something else. We don't have enough information to know.
I would recommend that you step through your code one line at a time in the debugger so you can understand at which step ffmin is made a cell array. Then you should be able to figure out how to fix the problem.

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by