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

 Réponse acceptée

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

4 commentaires

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
Absolutely perfect, thank you sir!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur App Building dans Centre d'aide et File Exchange

Produits

Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by