Convert string cell array to string literal

16 Ansichten (letzte 30 Tage)
Kumar Abhinav
Kumar Abhinav am 22 Jun. 2020
Beantwortet: Star Strider am 22 Jun. 2020
fileval = 'xxx_yyy_zzz'
nm1parts = split(fileval,'_');
fpart = '';
for ii = 1:length(nm1parts)
if ii~=length(nm1parts)
%fpart = fpart + string(nm1parts{ii}) + '\'
fpart = strcat(fpart, string(nm1parts{ii}), filesep);
else
%fpart = fpart + string(nm1parts{ii})
fpart = strcat(fpart, string(nm1parts{ii}));
end
end
whos fpart
nmdir = 'C:\Users\train'
mnm0 = [nmdir filesep fpart '.obj']
Here is my code, when I am trying to append to get the file path, it creates string cell array rather than a single string. Please help
output of mnm0- mnm0 =
1×4 string array
"C:\Users\train" "\" "xxx\yyy\zzz" ".obj"
what I want is - 'C:\Users\train\xxx\yyy\zzz.obj"

Antworten (1)

Star Strider
Star Strider am 22 Jun. 2020
There are two functions that will do that and the reverse: fullfile and fileparts.

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by