0

i have the code below :

if encoded(i)==code1(2,j)

that is a simple line and basically i want to save a specific element from a cell array named code1 into another array named encoded. The problem here is that matlab shows the below message:

Undefined operator == for input arguments of type cell. Is there any solution to this problem? How can i save an element from a cell array into a normal array in MATLAB?

1
  • 2
    Use curly braces: code1{2,j} Commented Jun 10, 2020 at 2:15

1 Answer 1

0

Use the function cellfun. Depending on the type of data in code1{2,j}, the first argument of the cellfun should be an appropriate function.

For example, if code1{2,j} is a string, use

cellfun(@str2double, code1{2,j})

Alternatively, if code1{2,j} is an array, use cell2mat as

cell2mat(code1{2,j})
Sign up to request clarification or add additional context in comments.

2 Comments

if both encoded and code1 are cell arrays what should i do then?
@ΓιάννηςΓιαννάκος A minimal reproducible example added to your question would be very helpful in providing a relevant answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.