I have written a function "test1.m" which is calling another function "foo.m" that is created dynamically during runtime. foo.m will not be found since it did not exist on the path when binding the functions before execution.Consequently running test1 produces an error. However the example works when including a WHICH or EXIST command. It also works in debug mode.
Ignoring the fact this example is very questionable programming style I would expect that:
1. The behavior in debugging mode and normal execution mode should be the same.
2. It should be mentioned in the documentation that WHICH and EXIST do perform something like a "refresh bindings" callback.
function out=test1 fid = fopen('foo.m','w'); fprintf(fid, '%s\n', 'function out = foo'); fprintf(fid, '%s\n', ' out=''foo executed ''; '); fclose(fid); %if exist('foo.m','file'), disp('found foo'); end
%which -all foo
out=foo; delete('foo.m');end
Best Answer