Double vs. Cell "Undefined function 'plus' for input arguments of type 'cell' "
显示 更早的评论
In my code, I have two variables (inp.W{9} & inp.W{10}) which seems to be double (when I remove semicolon, this is shown in command Window: ans = [1x10 double]). However when I try to add these two variables, I get this error:
Undefined function 'plus' for input arguments of type 'cell'.
Error in truck (line 21) inp.W{9}+inp.W{10}
回答(2 个)
Star Strider
2015-6-30
Without having them to experiment with and provide more specific code, I would use cell2mat to convert them first:
W9 = cell2mat(inp.W{9});
W10 = cell2mat(inp.W{10});
Result = W9 + W10;
4 个评论
Sam136
2015-6-30
Star Strider
2015-6-30
Without actually having your data, it’s difficult to provide an appropriate response. There are simply too many possibilities. It’s always possible any of us could guess the correct one, but that is a less than productive effort.
Sam136
2015-6-30
Star Strider
2015-6-30
It’s not code but your data that we need to determine your problem.
First, save your ‘inp’ structure as a .mat file, then attach it using the ‘paperclip’ icon.
Walter Roberson
2015-6-30
When you see
[1x10 double]
instead of numbers, then you are looking at a cell rather than a numeric array. Use
inp.W{9}{1}+inp.W{10}{1}
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Identification 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!