如何在 MATLAB 中连接字符串
我尝试执行以下操作:
fname = strcat('C:\Users\user_name\work\video\',avi_name);
videoObject = VideoReader(fname);
我收到一条错误消息:
Argument must contain a string.
我尝试检查我的 fname
是什么:
fname = strcat('C:\Users\user_name\work\video\',avi_name);
fname
videoObject = VideoReader(fname);
我看到它是(如预期):
'C:\Users\user_name\work\video\bla_bla.avi'
当我尝试执行以下操作时:
fname = 'C:\Users\user_name\work\video\bla_bla.avi';
videoObject = VideoReader(fname);
它有效。谁能解释一下 strcat
的输出有什么问题吗?为什么函数没有将其识别为字符串以及为什么它在输出中看起来像正确的字符串?
I try to do the following:
fname = strcat('C:\Users\user_name\work\video\',avi_name);
videoObject = VideoReader(fname);
I get an error message:
Argument must contain a string.
I try to check what is my fname
:
fname = strcat('C:\Users\user_name\work\video\',avi_name);
fname
videoObject = VideoReader(fname);
I see that it is (as expected):
'C:\Users\user_name\work\video\bla_bla.avi'
When I try to do the following:
fname = 'C:\Users\user_name\work\video\bla_bla.avi';
videoObject = VideoReader(fname);
It works. Can anybody explain me what is wrong with the output of strcat
. Why it is not recognized as a string by the function and why it does look like a correct string in the output?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 avi_name 是元胞数组,则 strcat 的输出也将是元胞数组(这就是显示字符串时带有引号的原因)。
使用
If
avi_name
is a cell array, then the output ofstrcat
will be a cell array as well (that's why the string comes with quotation marks when you display it).Use