execute function fil.m on my GUI ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
lakhdhar
el 30 de Abr. de 2014
Hi everybody ,
I wrote a function called ex.m that displays a video with some specific properties Now I want that when I clic on a buttom on my GUI this video is displayed in the choosen axes , I want something like : axes(handles.axes3),ex.m;
Is that possible ?!
0 comentarios
Respuesta aceptada
Roberto
el 6 de Mayo de 2014
Editada: Roberto
el 6 de Mayo de 2014
this creates a figure with a button that executes the function ex.m
h.figure = figure ;
h.axes = axes ;
uicontrol(h.figure,'style','pushbutton','String','Execute','Callback',@ex)
If you already have the axes created in a GUI you just have to set the current axes inside your code.
axes(handles.axes3);
imshow(I_RGB)
hold on ;
rectangle('Position',[Z,Z,s(2)-(2*Z),s(1)-(2*Z)],'EdgeColor','r','LineWidth',2 );
for k = 1:idx
rectangle('Position',boundingboxes,'EdgeColor','g','LineWidth',2 );
end
but be careful... handles.axes3 is a variable that only exists in your GUI function file this means that this variable does not exist in your ex.m file, one way to do what you want, is passing the handle variable as an argument to the function ex.m, other wise you'll get an error message, other way to accomplish this, is via nested functions, but all this depends on how your ex.m and myGUI.m functions are coded!
AGAIN IF I DON'T KNOW HOW IS YOUR CODE I CAN'T GIVE YOU A SIMPLE SOLUTION!!! JUST SIMPLE IDEAS OF HOW-TO DO IT
I'm going to try to give you an idea how to do it:
:file myGUI.m
handles.figure = figure ;
handles.axes3 = axes ;
uicontrol(handles.figure,'style','pushbutton',...
'String','Execute',...
'Callback',{@ex,handles});
:file ex.m
function argout = ex(handles)
...
...
% your code
...
...
axes(handles.axes3);
imshow(I_RGB)
hold on ;
rectangle('Position',[Z,Z,s(2)-(2*Z),s(1)-(2*Z)],'EdgeColor','r','LineWidth',2 );
for k = 1:idx
rectangle('Position',boundingboxes,'EdgeColor','g','LineWidth',2 );
end
0 comentarios
Más respuestas (2)
Roberto
el 30 de Abr. de 2014
I don't know how's your code, but a simple way of doing it is as follows:
h.figure = figure ;
h.axes = axes ;
uicontrol(h.figure,'style','pushbutton','String','Execute','Callback',@ex)
0 comentarios
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!