execute function fil.m on my GUI ?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Roberto
il 6 Mag 2014
Modificato: Roberto
il 6 Mag 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 Commenti
Più risposte (2)
Roberto
il 30 Apr 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 Commenti
Vedere anche
Categorie
Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!