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)]});');

采纳的回答

Walter Roberson
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 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by