Delwin Tanto
Delwin Tanto

Reputation: 13

Undefined function 'eq' for input arguments of type 'cell'

I tried to make a function that generates a number of strings.

function [p] = GetPattern (v)
load('code128B.mat')

for a=1:length(code128B)
    if v == code128B(a,1)
        p=code128B{a,3};
    end
end

code128B.mat contains data, first column are numbers while third column are strings. I want to input numbers and produce a string. why this function produce an error: Undefined function 'eq' for input arguments of type 'cell'.? I don't get it.

Thanks for any help.

Upvotes: 1

Views: 28775

Answers (1)

Mohsen Nosratinia
Mohsen Nosratinia

Reputation: 9864

For cell arrays, curly braces ({}) are used to extract the contents of the cells, while parentheses (()) are used to extract a subset of the cells (that is, the result is also a cell array).

Use code128B{a,1} instead of code128B(a,1) to get the number instead of a cell containing the number. However, if v is also a cell then you have to use isequal to compare their contents.

Upvotes: 6

Related Questions