How to pass values between callback functions in GUI?
5 次查看(过去 30 天)
显示 更早的评论
I know my question have been repeated many time in this platform, but since I have tried some suggested answers and get nothing to solve my problem, I am writing this question. I have made a GUI that includes different components. My general problem is how to pass values of different callback functions from one to other. For example in my GUI, I have two push-button callbacks, one for plotting and the other one for clearing the figure, that is out of GUI window/figure.
function pbplot_Callback(hObject, eventdata,handles) % plotting function (push-button)
figure (1)
plot(x,y, 'color', [a b c], 'linestyle', d)
hplot = findobj('Type','figure');
hold on % this is for adding new graphs
handles.hplot = hplot
guidata(hObject,handles)
function pbclear_Callback(hObject, eventdata,handles) % clearing function (push-button)
hplot = handles.hplot;
clf (hplot)
guidata(hObject,handles)
The error I get when I push the plot push-button is "Attempt to reference field of non-structure array." referring to "guidata(hObject.handles)". Getting information from handels, within plot callback function, shows "hplot: {2x1 double]". Could someone please help me to find the problem.
PS: x,y,a,b,c, and d are intorduced to the plot callback function.
2 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!