开发者

How to connect strings in MATLAB

开发者 https://www.devze.com 2023-04-12 20:50 出处:网络
I try to do the following: fname = strcat(\'C:\\Users\\user_name\\work\\video\\\',avi_name); videoObject = VideoReader(fname);

I try to do the following:

fname = strcat('C:\Users\user_name\work\video\',avi_name);
videoObject = VideoReader(fname);

I开发者_StackOverflow社区 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?


If avi_name is a cell array, then the output of strcat will be a cell array as well (that's why the string comes with quotation marks when you display it).

Use

fname = strcat('C:\Users\user_name\work\video\',avi_name{1});
0

精彩评论

暂无评论...
验证码 换一张
取 消