User`s guide
12 Limitations and Restriction s
Workaround
There are several ways to eliminate this error.
• Using the
%#function pragma and specifying callbacks as strings
• Specifying callbacks with function handles
• Using the
-a option
Specifying Callbacks as Strings. Create a list of all the functions that are
specified only in callback strings and pass these functions using separate
%#function pragma statements. T his overrides MATLAB Compile r’s
dependency analysis and instructs it to explicitly include the functions listed
in the
%#function pragmas.
For example, the call to the
change_colormap function in the sample
application,
my_test, illustrates this problem. To make sure MATLAB
Compiler processes the
change_colormap M-file, list the fu nction name in the
%#function pragma.
function my_test()
% Graphics library callback test application
%#function change_colo rmap
peaks;
p_btn = uicontrol(gcf,...
'Style', 'pushbutton' ,...
'Position',[10 10 133 25 ],...
'String', 'Make Black & White',...
'CallBack','change_colormap');
Specifying Callba ck s with F unction Handles. To specify the callbacks
with function handles, use the same code as in the example above and replace
thelastlinewith
'CallBack',@change_colormap);
12-4