3

I've a M by N matrix, each cell contains a character array, that is an image path. How can I use it to read image? It should be string.

It's what I try to do:

imread(fl(1,1));
??? Error using ==> imread>parse_inputs at 491
The filename or url argument must be a string.

Error in ==> imread at 336
[filename, fmt_s, extraArgs, msg] = parse_inputs(varargin{:});

And it's my matrix: enter image description here

1 Answer 1

7

Replace fl(1,1) with fl{1,1}. You access the contents of a cell-array with {}. You access the cell element itself with ().

Since imread expects a string and not a cell element, it throws that error.

Sign up to request clarification or add additional context in comments.

1 Comment

There is no "cell element". For cell matrices, the () operator returns a (sub-)cell matrix. It just happens that when you pass in scalars (as opposed to vectors), the returned cell is of size 1-by-1.

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.