Loading a Histogram in a GUI with data from another Function

1 次查看(过去 30 天)
I'm looking at using a push-button in a GUI to load up a histogram of an image that is already loaded into the GUI. I don't think I've got the handles quite right, can anyone suggest what im doing wrong?
Code below
Many Thanks
Luke
%%CallBack
set(h.buttonone, 'callback', {@addaxes1, h});
set(h.buttontwo, 'callback', {@applywindow, h});
set(h.buttonthree, 'callback', {@Hg, Im2, h});
then in seperate function (@Hg)
function Hg = Hg(hObject, eventdata, h);
subplot(1, 2, 2);
y = histogram(Im2), h.axes2;
I keep getting an error saying
"Error using Hg
Too many input arguments"
This error refers to the top line of function Hg.

回答(2 个)

Geoff Hayes
Geoff Hayes 2016-3-5
Luke - I wonder if the problem is with the signature of your function
function Hg = Hg(hObject, eventdata, h);
You have named this function Hg but are also trying to return a parameter named Hg. What is the intent? How is this output variable used? Is it even necessary?
Also, please clarify when the above error occurs. (i.e. in response to what action by the user.)

Image Analyst
Image Analyst 2016-3-5
Try this:
function histObject = Hg(yourImage, handlesStructure);
subplot(1, 2, 2);
histObject = histogram(Im2);
% Switch current axes to axes2:
axes(handlesStructure.axes2);

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by