首页 > 代码库 > Convert character array to string in MATLAB
Convert character array to string in MATLAB
Matlab提取特征值是经常要读取多个图片文件,把文件名保存在数组中后再读取会出错。从stackoverflow中找到如下解决方法:
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 491The filename or url argument must be a string.Error in ==> imread at 336[filename, fmt_s, extraArgs, msg] = parse_inputs(varargin{:});
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.
Convert character array to string in MATLAB
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。