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

I am getting this error-"Undefined operator '*' for input arguments of type 'cell'".
for i = 1 : r
schedule_time{i} = sum(table(i, 2), hold_time(i, 1));
end

5 件のコメント

Adam
Adam 2018 年 3 月 19 日
Yes, as the error says, + is not defined for cells. What is 'table'? If it is a cell array then you presumably want to use
table{ i, 2 }
instead, to access its contents. Likewise for hold_time.
Stephen23
Stephen23 2018 年 3 月 19 日
編集済み: Stephen23 2018 年 3 月 19 日
@Amrita Datta: I am having trouble following your question: you have listed two different error messages, both of which are unrelated to the code that you have shown us. You also gave no information on any of the variables involved. If we don't know what is going on then it makes helping you very difficult.
Amrita Datta
Amrita Datta 2018 年 3 月 19 日
編集済み: Amrita Datta 2018 年 3 月 19 日
sorry for typing miss take. Undefined operator '+' for input arguments of type 'cell' for i = 1 : r schedule_time{i} = table(i, 2) + hold_time(i, 1); end another try but same error.
Adam
Adam 2018 年 3 月 19 日
編集済み: Adam 2018 年 3 月 19 日
Then use { } like I said.
And don't name a variable table - it's a builtin data type.
Guillaume
Guillaume 2018 年 3 月 19 日
I think it's a bit more complicated than just replacing () by {},
sum(table{i, 2}, hold_time(i, 1))
would only make sense, if table{i, 2} contained an arrat with at least as many dimensions as the scalar value hold_time(i, 1), in which case hold_time would be a very misleading name and the variable would indicate which dimension to sum.
Somehow I don't think that's the case. Possibly, the sum is supposed to be a plain + operation.
As Stephen said, not enough information has been provided. What are the types of table and hold_time and what is the intent of the code?

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLanguage Support についてさらに検索

タグ

質問済み:

2018 年 3 月 19 日

コメント済み:

2018 年 3 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by