Reputation: 924
The MATLAB builtin "LOAD" can be called using an argument (the filename) and it modifies the workspace by adding the loaded variable, even if there are no output arguments to the function.
I want to do the same with a custom function.
So I want to implement a custom load function, how do I do this?
Upvotes: 0
Views: 116
Reputation: 21563
I am guessing what you want, but I suppose this may be it:
If you want to create the functionality like load
create a function called myLoad
function myload(theString)
evalin(['load ' theString],'caller')
At least this should reproduce the basic functionality
To create a load script that loads file A
from myDir1 and loads file B
from myDir2 there is an easier way:
load fullfile(myDir1,A)
load fullfile(myDir2,B)
Just put them in a file called myLoad
and make sure to save it as a script, not as a function.
Upvotes: 1