file - changing folder name, matlab -
i want set path text file programmatically. e.g.,
file = 'h:\user4\matlab\myfile.txt'; [pathstr, name, ext] = fileparts(file) pathstr = h:\user4\matlab name = myfile ext = .txt
i want write file in h:\user4\myfile
. how can name.
i want newfilepath=strcat(pathstr,'myfile').
obviously gives h:\user4\matlab\myfile
don't want. how can write code.
get parent path manually:
islashes = strfind(pathstr,filesep()); newfilepath=fullfile(pathstr(1:islashes(end)),'..','myfile')
which uses fullfile, filesep , strfind. fullfile
nice concatenate strings while working files , paths.
or use '..'
matlab understand , refer parent directory of preceding directory:
newfilepath=fullfile(pathstr,'..','myfile')
Comments
Post a Comment