|
I'd like to overload Matlab's built-in import statement. Let's say I write a function like so:
function[] = import(varargin)
if strcmpi(varargin{1}, '3')
fprintf('Yay, I got a 3! \n');
else
call_matlabs_builtin_import_using_nasty_evalin_statement
end
Now if save this function and put it in my path:
1.) matlab yells at me about overloading functions. Fine.
2.) I can run
>> import 3
from the command line and get the desired result
However, if I put the statement
import 3
into a script or a function, Matlab does some sneaky preprocessing that automatically checks the syntax of things after the import statement. It appears to do this in it's preprocessing optimization step, and it throws the error:
??? Error: File: blah.m Line: 3 Column: 8
Arguments to IMPORT must either end with ".*"
or else specify a fully qualified class name: "3" fails this test.
(blah.m was the script file I created). Clearly Matlab is doing some error checking before running the code...and I'd like to make it stop.
Any ideas?
|