From: Nicky on
I am trying to add a function I created to the general Matlab directory so I can call it regardless of my current directory, is there a way to do this? So right now say I have a function called fun1.m. I can currently call fun1(input) if the file is in my current directory, but I want to make it universal, is there a source folder that Matlab installs somewhere is Program Files or something? Thank you for any help!
From: us on
On Mar 30, 5:32 pm, "Nicky " <nickdog1...(a)yahoo.com> wrote:
> I am trying to add a function I created to the general Matlab directory so I can call it regardless of my current directory, is there a way to do this? So right now say I have a function called fun1.m. I can currently call fun1(input) if the file is in my current directory, but I want to make it universal, is there a source folder that Matlab installs somewhere is Program Files or something? Thank you for any help!

a hint:
- create a folder, which is NOT inside the default/root ML path(!)...
- add it to your ML path

help matlabroot;
help path;
help addpath;

us
From: ImageAnalyst on
Nicky
What I do is to have these lines in my startup.m file:
addpath(genpath('C:\Program Files\MATLAB\Work'));
cd 'C:\Program Files\MATLAB\work'
savepath;

Then I put all of my MATLAB projects in subfolders of the work
folder. MATLAB automatically starts with the current folder as C:
\Program Files\MATLAB\Work, plus all of those folders are on the path
automatically so any of my m files can call any other one (because the
other one will be on the path).