0
votes

In my matlab script I would like to output some files in a specific folder. My function will accept a path to the desired folder and will check for its existance, but I would also like to implement a default behaviour consisting in saving everything in a default folder (named with day and time) located in the document folder of the computer.

Looking around I found some suggestion (get 'Documents' path in Matlab) on how to detect the correct folder in specific conditions (let's say a Windows PC, the default document folder, something with a specific name, ...). Is there anything more general, usable for all platforms (Win, Mac and Unix)? Or should I implement some switch?

Thanks.

1
This question could almost entirely be summed up with "is there a system-independent way to get the default documents path in MATLAB", the answer to which is documented to be userpath - Wolfie

1 Answers

0
votes

Just making an answer out of Wolfie's comment.

Directly taken from Matlab documentation:

userpath('reset') sets the first folder on the search path to the default for your platform. The default userpath folder is platform-specific.

Windows® platforms — %USERPROFILE%/Documents/MATLAB.

Mac platforms — $home/Documents/MATLAB.

Linux® platforms — $home/Documents/MATLAB if $home/Documents exists.