Matlab strcat not returning string?

imgstr cannot recognize the output string from strcat.

homedir = 'C:\Users\...\images\';
for img = {'01.bmp', '02.bmp', '03.bmp'}
  imgstr = strcat(homedir, img)
  I = imread(imgstr);
end;

      

outputs:

imgstr = 'C:\Users...\images\01.bmp'
Error using imread>parse_inputs (line 477)
The filename or url argument must be a string.

      

strcat should return a string, not a char array, since my inputs are strings. Is not it?

+3


source to share


1 answer


Your problem is how MATLAB iterates over cell arrays. Here is a related question / answer.

Inside the loop, add {1}

to extract the char array and it should work:



imgstr = strcat(homedir, img{1})

      

+6


source







All Articles