From: Julien Mottet on
Hello,

How can i automatically update the setpath with all the m functions contained in the folders and the subfolders of a given directory.
"Automatically" means without doing - file>setPAth.

A solution might be :
creating a function which would be automatically launched everytime i open matlab and which scans the folder containing my Matlab functions, detects the eventual new folders and adds it to the setpath.

if this idea is good could you tell me how to do it...
and if there is a better way...let me know :)

regards

Julien
From: ImageAnalyst on
Julien
Put this line in your startup.m file:
addpath(genpath('C:\Program Files\MATLAB\Work'));
Give it whatever folder you want. It will run this when MATLAB
launches and do what you asked.

From: Matthew Whitaker on
"Julien Mottet" <mottet.julien123(a)gmail.com> wrote in message <hleqvn$jf9$1(a)fred.mathworks.com>...
> Hello,
>
> How can i automatically update the setpath with all the m functions contained in the folders and the subfolders of a given directory.
> "Automatically" means without doing - file>setPAth.
>
> A solution might be :
> creating a function which would be automatically launched everytime i open matlab and which scans the folder containing my Matlab functions, detects the eventual new folders and adds it to the setpath.
>
> if this idea is good could you tell me how to do it...
> and if there is a better way...let me know :)
>
> regards
>
> Julien

If you want to add a folder and all its subfolders to the path then do:
addpath(genpath(pn)); %add path and all subpaths where pn is the top level path

To save the path once you've changed for future sessions:
saveError = savepath;

To reset the path to its default state:
restoredefaultpath

If you want to create startup functions put them in a file called startup.m on your path.

I have a utility I wrote internally to manage different path configurations for different projects. I'll see if I can put into a form suitable for the FEX.

Hope this helps
Matt W