Clear Filters
Clear Filters

wait until picture selection.

2 views (last 30 days)
Dimani4
Dimani4 on 10 Mar 2022
Commented: Dimani4 on 12 Mar 2022
Hi people,
I have some gui program in matlab. I create some pictures. Then I want to do profile on the pictures. I created push button, say "Manual profile". I push this button and then I want to program to wait until I will select between some pictures I already created.
function pushbutton15_Callback(hObject, eventdata, handles) %(manual profile button)
% hObject handle to pushbutton15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%? what should be here?
% Here I want to wait until I select some picture
Then my purpose is to get handle to the selected figure and pass it to the function of improfile. In that way I want to create the profile on selected picture.
Thank you very much.

Accepted Answer

Jan
Jan on 10 Mar 2022
Edited: Jan on 10 Mar 2022
You could add a button "Select this" to all open figures:
function pushbutton15_Callback(hObject, eventdata, handles)
openFig = get(groot, 'Children');
hButton = gobjects(1, numel(openFig));
hFig = ancestor(hObject, 'Figure');
for k = 1:numel(openFig)
hButton(k) = uicontrol(openFig(k), 'Style', 'PushButton', ...
'String', 'Select', ...
'Callback', {@selectBtn_Callback, handles, hFig});
end
setappdata(hFig, 'SelectButton', hButton);
end
function selectBtn_Callback(hObject, eventdata, handles, hFig)
hSelectedFigure = ancestor(hObject, 'Figure');
hButton = getappdata(hFig, 'SelectButton');
delete(hButton);
setappdata(hFig, 'SelectButton', []);
... do with hSelectedFigure what you want now
end
  1 Comment
Dimani4
Dimani4 on 12 Mar 2022
Thank you very much!!!!! Great solution!!!!

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!