A rough app I have recreated.When the user clicks "Calculate", I want to show that calculations are happening like a progress bar or "Calculate" Button changes to "Calculating" and after calculations are done revert back to "Calculate". Code for app is:
a = app.Number1EditField.Value;
b = app.Number2EditField.Value;
x = 10*rand(1,1);
eqn = 12- (a b x);
while eqn ~= 0
x = x 0.0001;
end
app.AnswerEditField.Value = x;
P.S I know here the answer won't come.
CodePudding user response:
If you create a gui with the appdesigner, and have a pushbutton with handle calculateButton
, you can use the following as its callback:
% Button pushed function: calculateButton
function calculateButtonPushed(app, event)
set(app.UIFigure,'Pointer','watch'); drawnow;
app.calculateButton.Text = 'Calculating...';
pause(2); % calculate whatever, pause for demo
set(app.UIFigure,'Pointer','arrow'); drawnow;
app.calculateButton.Text = 'Calculate';
end
This will both change the text, and change the pointer to a wait cursor.
CodePudding user response:
You can use uiprogressdlg
to create a (modal) progress bar.