Smart way of adding paths

조회 수: 3 (최근 30일)
feynman feynman
feynman feynman 2024년 3월 5일
답변: Steven Lord 2024년 3월 5일
For those using multiple PCs, it is necessary to use a smart way of adding paths. How is it possible to add paths like:
a='c:\folder1\'% PC1
b='d:\folder2\'% PC2
c='folder3\'
if PC1
addpath concatenate(a,c)
else
addpath concatenate(b,c)
end
so that when using PC1, addpath 'c:\folder1\folder3\'.

채택된 답변

Steven Lord
Steven Lord 2024년 3월 5일
Use fullfile.
a='c:\folder1\'% PC1
a = 'c:\folder1\'
b='d:\folder2\'% PC2
b = 'd:\folder2\'
c='folder3\'
c = 'folder3\'
P = fullfile(a, c)
P = 'c:\folder1\/folder3\'
Note that the MATLAB that MATLAB Answers uses to run code in answers is on Linux, so fullfile will add the appropriate
filesep
ans = '/'
between the two parts of the path. If you ran this on Windows the / character would not be present in P.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Gravitation, Cosmology & Astrophysics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by