How to correct for 'Undefined function 'eq' for input arguments of type 'cell'' error message
7 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a simple bit of code and keep getting an error message,
>>
for Area = 1:652
if Area == out(:,1)
DateofB = out(:,2)
LocationSquare(Area) = DateofB
end
end
Undefined function 'eq' for input arguments of type 'cell'.
I've tried using curled braces instead in my if statement but that doesn't work.
I've also tried using an isequal term instead too but it doesn't like that either.
Am I going about this in the wrong way?
Thanks for any help, advice, direction that can be spared.
6 个评论
回答(2 个)
Matt J
2015-8-7
I've tried using curled braces instead in my if statement but that doesn't work.
See what you get when you do the following,
>> A={1,2,3};
>> if A{1}==1, disp 'Hello World', end
Hello World
>> if A==1, disp 'Hello World', end
Undefined operator '==' for input arguments of type 'cell'.
0 个评论
Walter Roberson
2015-8-11
indices = cell2mat(out(:,1));
LocationSquare(indices) = out(indices,2);
No loop.
Note: this relies upon out(:,1) always being valid and unique.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!