Convert string cell array to string literal

16 visualizzazioni (ultimi 30 giorni)
Kumar Abhinav
Kumar Abhinav il 22 Giu 2020
Risposto: Star Strider il 22 Giu 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"

Risposte (1)

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

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by