To: "John W. Eaton" <
On Wed, Apr 22, 2009 at 8:50 PM, John W. Eaton
<address@hidden> wrote:
Create directories d1 and d2. Put the following fucntion in
d1/crash.m:
function crash ()
'd1/crash'
and put the following function in d2/crash.m:
function crash ()
'd2/crash'
Now start Matlab in the directory that contains d1 and d2, and run the
following commands:
fh = @crash
fh ()
cd d1
fh ()
cd ../d2
fh ()
>> fh = @crash
fh =
@crash
>> fh ()
??? Undefined function or variable 'crash'.
>> cd d1
>> fh ()
ans =
d1/crash
>> cd ../d2
>> fh ()
ans =
d2/crash
clear all
fh = @crash
cd ..
fh ()
cd d1
fh ()
>> clear all
>> fh = @crash
fh =
@crash
>> cd ..
>> fh ()
ans =
d2/crash
>> cd d1
>> fh ()
ans =
d2/crash
Now, while Matlab is still running, change the definition of
d2/crash.m to be
function crash ()
'foo'
and then continue your Matlab session with the following commands:
fh ()
cd ..
fh ()
cd d2
fh ()
>> fh ()
ans =
d2/crash
>> cd ..
>> fh ()
ans =
d2/crash
>> cd d2
>> fh ()
ans =
foo
clear all
addpath (pwd)
cd ..
fh = @crash
fh ()
>> clear all
>> addpath(pwd)
>> cd ..
>> fh = @crash
fh =
@crash
>> fh ()
ans =
foo
Now, while Matlab is still running, change the definition of
d2/crash.m to be
function crash ()
'bar'
and then continue your Matlab session with the following commands:
fh ()
cd d1
fh ()
cd ../d2
fh ()
>> fh ()
ans =
bar
>> cd d1
>> fh ()
ans =
bar
>> cd ../d2
>> fh ()
ans =
bar