Fixing File Paths to Run on Multiple Computers

조회 수: 8 (최근 30일)
Nat Person
Nat Person 2021년 1월 7일
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.

답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by