Smart way of adding paths
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
feynman feynman
le 5 Mar 2024
Réponse apportée : Steven Lord
le 5 Mar 2024
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\'.
0 commentaires
Réponse acceptée
Steven Lord
le 5 Mar 2024
Use fullfile.
a='c:\folder1\'% PC1
b='d:\folder2\'% PC2
c='folder3\'
P = fullfile(a, c)
Note that the MATLAB that MATLAB Answers uses to run code in answers is on Linux, so fullfile will add the appropriate
filesep
between the two parts of the path. If you ran this on Windows the / character would not be present in P.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Gravitation, Cosmology & Astrophysics dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!