Fixing File Paths to Run on Multiple Computers

7 visualizaciones (últimos 30 días)
Nat Person
Nat Person el 7 de En. de 2021
I have a Matlab program that needs to run on multiple computers, however the program searches for folders that are outside of the directory. I am stuggling to figure out how I can change file paths so that they work on multiple computers.
Here's my issue:
if ~exist('C:\Users\nperson\Desktop\F-DAS Matlab\ProcessFiles', 'dir') %check to see if processfiles folder exists
mkdir('C:\Users\nperson\Desktop\F-DAS Matlab\','ProcessFiles') %create the folder if it doesn't
end
cd('C:\Users\nperson\Desktop\F-DAS Matlab\ProcessFiles') %change current directory to processfiles
copyfile('C:\Users\nperson\Desktop\F-DAS Matlab\RAW', 'C:\Users\nperson\Desktop\F-DAS Matlab\ProcessFiles') %copy files from RAW data to the processfiles folder
As you can see all file paths use 'C:\Users\nperson\Desktop\F-DAS Matlab\..' which will only work on my computer, how can I use relative file paths so it works on multiple computers.

Respuestas (0)

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by