Azzera filtri
Azzera filtri

I want to call a msgbox using pushbutton. How can I do it given I am not using guide?

3 visualizzazioni (ultimi 30 giorni)
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)]});');

Risposta accettata

Walter Roberson
Walter Roberson il 13 Lug 2016
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!'');'

Più risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by