I want to call a msgbox using pushbutton. How can I do it given I am not using guide?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Atul Vaibhav
am 13 Jul. 2016
Beantwortet: Walter Roberson
am 13 Jul. 2016
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 13 Jul. 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!'');'
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!