I want to call a msgbox using pushbutton. How can I do it given I am not using guide?
3 次查看(过去 30 天)
显示 更早的评论
I have created a pushbutton in which I want the msgbox to be called on & display four values when the button is pushed. I have tried the following but It's showing error.
S.btn5 = uicontrol('style','pushbutton','units','pixels',...
'position',[c a-70 170 50],'fontsize',14,'string','Calculate', ...
'callback', 'x=linprog(f,A,b,Aeq,beq); z=abs(transpose(f)*x);msgbox({['Source 1 =' num2str(x(1))],['Source 2 = 'num2str(x(2))],['Source 3 =' num2str(x(3))],['Output =' num2str(z)]});');
0 个评论
采纳的回答
Walter Roberson
2016-7-13
Even though you are not using GUIDE, I recommend that you put the callback code into a function and invoke the function in the callback.
When you code a callback as a string (the way you have) the variables are fetched from the base workspace.
One difficulty that you have is that you are trying to put quote marks inside of quote marks. To do that you need to double the inside quote marks. For example,
'callback', 'msgbox(''hello!'');'
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!