execute function fil.m on my GUI ?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Roberto
le 6 Mai 2014
Modifié(e) : Roberto
le 6 Mai 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 commentaires
Plus de réponses (2)
Roberto
le 30 Avr 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 commentaires
Voir également
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!