Fixing File Paths to Run on Multiple Computers
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!