Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert character array to string in MATLAB

Tags:

string

matlab

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

like image 627
Maysam Avatar asked Jul 02 '26 03:07

Maysam


1 Answers

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.

like image 194
Jacob Avatar answered Jul 04 '26 01:07

Jacob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!