Generating C code from MATLAB GUI

6 views (last 30 days)
Matthieu
Matthieu on 23 Jan 2013
hello,
here is my problem, I created a GUI with GUIDE, I then exported in .m, and when I want generated C++ code from Matlab Coder I m obtien an error:
Error:
Code >>-build test.prj
??? This kind of speech is not supported
My code:
h6 = uicontrol(...
'Parent',h5,...
'Units','characters',...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',@(hObject,eventdata)interfasetest_export3('pushbutton1_Callback',hObject,eventdata,guidata(hObject)),...
'Position',[3.66666666666667 2 25.1666666666667 2.41666666666667],...
'String','Ouvrir fichier .AVI',...
'Tag','pushbutton1',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
Matlab Coder do not know the syntax with the @:
@(hObject,eventdata)interfasetest_export3('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Thank you for your help and I'm sorry for my english, I'm french.

Answers (1)

Ryan Livingston
Ryan Livingston on 23 Jan 2013
Hi Matthieu,
Unfortunately MATLAB Coder does not support using anonymous functions like:
@(hObject,eventdata)interfasetest_export3('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Moreover, gui code generation is not supported. If your intention is to share the GUI functionality or deploy it to other users without needing MATLAB then MATLAB Compiler may allow you to do this.
Using MATLAB Compiler you can essentially wrap up your application into an executable or library which can then be called from C/C++ or various other targets using the Builder products. This can then be distributed to others along with a set of runtime libraries called the MCR and used without MATLAB.
Here is a small example of using MATLAB Compiler:
~Ryan
  2 Comments
Matthieu
Matthieu on 28 Jan 2013
Hello, the problem is that I do not want to use Matlab Compiler because to distribute my program it will install Matlab MCR runtime on PC and I don't want, I just want one .exe and it's all done.
cordially
Walter Roberson
Walter Roberson on 28 Jan 2013
In that case, you will need to write your own graphics functions. MATLAB Coder is not able to generate any graphics code.
You can avoid using anonymous functions using one of the techniques described at http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F

Sign in to comment.

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!