How to correct for 'Undefined function 'eq' for input arguments of type 'cell'' error message
조회 수: 6 (최근 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!