How to enable required buttons and plot linear fit from group of graphs
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vaibhavi Pallavaneni
le 21 Mai 2024
Modifié(e) : Vaibhavi Pallavaneni
le 29 Mai 2024
I have created an where i want to enable required buttons based on the input given. I have the maxium limit of the required buttons. My app tells about the mangoes quantity in the basket and the plot are made for the estimation of the ripeness of mangoes. Where i have known about the maximum number of mangoes in basket. What i required is, 1) if i change my input, i don't want the import excel buttons to be deleted instead those should be diabled. 2) After plotting the graphs, i want to make the linear fit and the squareroot fit to the plotted group of graphs. i have attached my app and the excel file for the plot.
0 commentaires
Réponse acceptée
Yatharth
le 27 Mai 2024
Hi Vahini,
From what I understood, you would like the import buttons to be disabled based on the input number.
You can use "app.Button.Enable" to toggle between the 'on' and 'off' states.
Here is an example code where I have 9 buttons, and based on the input number, the remaining buttons get disabled.
Function inputNumberFieldValueChanged(app, event)
value = app.inputNumberField.Value;
for i = 1:9
if i > value
app.(['Button_', num2str(i)]).Enable = 'off';
else
app.(['Button_', num2str(i)]).Enable = 'on';
end
end
end
For the second part of your question, You can use the "polyfit" function to plot the linear and square fit graph.
Here is a link to the example for the same. https://www.mathworks.com/help/matlab/ref/polyfit.html#:~:text=0%2C4*pi)%3B%0Ay1%20%3D-,polyval,-(p%2Cx1)%3B%0Afigure
Note: Use the "hold" function to plot on the same graph/ UIAxes.
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Objects dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!