MATLAB Answers

How can I change the folder used by "openExample"?

15 views (last 30 days)
I wanted to run a MATLAB/Simulink demo in R2021a and I need to run the "openExample" command to open it.
By default, the examples seem to be unpacked in this directory on Windows:
C:\Users\johndoe\Documents\MATLAB\Examples\R20xxx\toolbox\examplename
or
C:\Users\johndoe\OneDrive\Documents\MATLAB\Examples\R20xxx\toolbox\examplename
How can I change the path where the example files are unpacked to?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Mar 2021
Edited: MathWorks Support Team on 22 Mar 2021
There are two options to change the folder used by "openExample":
1. Change the folder used by one particular example
You can use the 'workDir' option to open one instance of an example in a different working directory:
>> E = 'uav/UAVPackageDeliveryExample';
>> openExample(E,'workDir','C:\Documents\')
2. Change the folder used for all examples (global setting)
The directory used by "openExample" is determined by the userpath:
You can set your userpath to a different directory by using the command:
>> userpath('C:\Documents\')

More Answers (0)

Community Treasure Hunt

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

Start Hunting!