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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -