managing files

This is, no doubt, a dumb beginner question.
How do you all manage experiment files in MatLab and Psychtoolbox?

That is, if I have an m fil, call it somefile.m, and it's in an experiment folder, and then (for
some reason) I have another file also called somefile.m in another folder, how does MatLab
know which one to use?

Is there a way in the experiment file to tell the system which folder to use?

Any tips on general file management for experiments would be great.
Thanks.

Ray Vukcevich
University of Oregon
I guess you probably already know it is generally a bad idea to have two
files with the same name. :-) Which one matlab uses depends on where
it is on the path.

General rules, I've come to live by (but in no way the only way to do
things):

Usually bad idea to keep mfiles in the matlab application folder (like
the toolbox), because matlab requires deleting the old folder when
installing an upgrade.

Create a matlab directory in your home directory. Make a file called
startup.m in that directory that sets the path you will use most often.
Matlab always checks for this file when it starts up. I find this
much easier than mucking with the path gui. You can make other mfiles
that add or remove directories to this path for specific experiences,
and run these before the experiments.

If you do add to the gui, be aware that where in the list you add a path
matters (when you use startup.m, the order also matters, but will
always be after the matlab built-in commands). If you made an mfile
called plot, and you have put your paths higher on the list than the
normal matlab directories, matlab will use your function instead of the
normal plot function. This is especially bad on os9, where everyone
uses the same saved pat, so on os9 I think it is especially important to
not use the gui, because you can mess up other people using the machine.

How the Search Path Determines Which Function to Use

The order of directories on the path is relevant. MATLAB looks for a
named element, for example, foo, as described here. If you enter foo at
the MATLAB prompt, MATLAB performs the following actions:

1. Looks for foo as a variable.
2. Looks in the current directory for a file named foo.m.
3. Searches the directories on the MATLAB search path, in order, for
foo as a built-in function, followed by foo.m which is not built-in.

If there is more than one function with the same name, the order of
directories on the path determines which of those functions MATLAB uses.
When MATLAB looks for that function, it uses the first one found in the
search path.

Use the command which to see the path for the function that is being used.

Hope this helps,

Maria



Ray Vukcevich wrote:
> This is, no doubt, a dumb beginner question.
> How do you all manage experiment files in MatLab and Psychtoolbox?
>
> That is, if I have an m fil, call it somefile.m, and it's in an experiment folder, and then (for
> some reason) I have another file also called somefile.m in another folder, how does MatLab
> know which one to use?
>
> Is there a way in the experiment file to tell the system which folder to use?
>
> Any tips on general file management for experiments would be great.
> Thanks.
>
> Ray Vukcevich
> University of Oregon
>
>
>
>
> Post your message to: psychtoolbox@yahoogroups.com
> Please indicate OS9, OSX, or WIN version, and include your full name.
> Denis Pelli, David Brainard, and Allen Ingling.
> http://psychtoolbox.org
>
> Yahoo! Groups Links
>
>
>
>
>
>