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 Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by