How to join a file path with multiple char vector or string in MatLab? - fullfile -- MatLab

How to join a file path with multiple char vector or string in MatLab? - fullfile -- MatLab

How to join a file path with multiple char vector or string in MatLab?

[Ans]
fullfile

[Description]
concatenate multiple char vector or string to a full file path.

more details on:

code:

f = fullfile('myfolder','mysubfolder','myfile.m')

output:

 f = 

'myfolder/mysubfolder/myfile.m'

code:
f = fullfile('c:\','myfiles','matlab',{'myfile1.m';'myfile2.m'})

output:
f =

  2×1 cell array

    'c:\myfiles\matlab\myfile1.m'
    'c:\myfiles\matlab\myfile2.m'

code:
f = fullfile('c:\folder1', '.\folder2', '..\folder3\.')

output:
f =

c:\folder1\folder2\..\folder3\.

code:
f = fullfile('c:\','myfiles','matlab',filesep)

output:
f =

c:\myfiles\matlab\

code:
f = fullfile('c:\folder1', '\\\folder2\\')

output:
f =

c:\folder1\folder2\
output:

Comments