本文介绍了Matlab的strcat不返回字符串吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
imgstr无法识别strcat的输出字符串.
imgstr can't 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;
输出:
imgstr = 'C:\Users...\images\01.bmp'
Error using imread>parse_inputs (line 477)
The filename or url argument must be a string.
strcat应该返回一个字符串,而不是char数组,因为我的输入是字符串.不是吗?
strcat should be returning a string, not a char array, since my inputs are strings. Shouldn't it?
推荐答案
您的问题是MATLAB如何遍历单元格数组. 这是一个相关的问题/答案.
Your problem is with how MATLAB iterates over cell arrays. Here's a related question/answer.
在循环内添加{1}
以提取char数组,它应该可以工作:
Inside the loop add a {1}
to extract the char array, and it should work:
imgstr = strcat(homedir, img{1})
这篇关于Matlab的strcat不返回字符串吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!