Sum of numeric field boxes must equal 100 before user can press a plot button.

I have four numeric field boxes on app designer where the user inputs a value between and including 0 and 100 for each box. Once the user has input this, they will press a plot button to run the program.
How can I make it such that the sum of the four numeric field boxes must equal 100, otherwise the user cannot press the plot button?
Thank you

 Accepted Answer

Check the attached app for an example of how it can be done.

4 Comments

Thank you for your answer Ameer.
Do you know how to make an error message appear for the user, if the sum does not equal 100, stating that they must sum to 100 in order to plot the graph?
Ashton, replace the if-end block, in the code view, with this
if value == 100
x = linspace(0,10);
y = sin(x);
plot(app.UIAxes, x, y);
else
msgbox('Sum is not 100', '', 'error');
end

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Release

R2019a

Community Treasure Hunt

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

Start Hunting!