add words to the end of a path
1 次查看(过去 30 天)
显示 更早的评论
Hi! I need to add the string or char my version or my version complete to the end of a path.
I tried this way but I can't find the solution. Thanks for the help!
pdest1 = 'C:\....\....\....\.....';
name = "my version";
% name1 = "my version complete";
strPieces = strsplit(pdest1,"\");
number_places = numel(strPieces);
strPieces(number_places + 1) = name; % or name1
number_places = numel(strPieces);
composition = strcat(strPieces(1:number_places));
final_str = join(composition, "\");
final_char = convertStringsToChars(final_str);
采纳的回答
Angelo Yeo
2023-6-16
pdest1 = 'C:\....\....\....\.....';
name = "my version";
string(pdest1) + name
1 个评论
Image Analyst
2023-6-16
pdest1 = 'C:\....\....\....\.....';
name = "my version";
fullFileName = fullfile(pdest1, name)
Note, the directions of the slashes doesn't matter in Windows - it will work regardless. It added a forward slash here probably because the server is a Unix server.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Name Construction 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!