Reputation: 2256
PHP has the nifty include()
function to bring in external files into the main script. Is this possible in Octave? I tried using load()
but I keep getting an error: error: load: unable to determine the file format of 't_whse.m'
which makes me think this is the wrong way to do this or that it's actually not possible in Octave.
Upvotes: 0
Views: 1015
Reputation: 65430
You don't need to call load
, as load
is reserved for loading data from a file. Instead, you just want to call the script by name. This will (if it's actually a script) execute the script and make any variables that were defined in that script accessible to the calling script.
script1.m
disp('Beginning of script1');
script2;
fprintf('Value = %d\n', value)
disp('End of script1')
script2.m
disp('Beginning of script2');
value = 2;
disp('End of script 2');
Upvotes: 1