Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Is an if statement needed to distinguish between two similar callbacks?

1 visualizzazione (ultimi 30 giorni)
I have two push buttons in my GUIDE window. One is for opening files and reformatting them while the other does exactly the same thing but bins the data in half to allow for it to be plotted more quickly. Currently I just have both callbacks in the guide, but because they use exactly the same variable names and handles, I was thinking i may need to install an if statement to say;
If push button 1 is pushed, push button 2 is unused, and vice versa.
My query is, do i need a statement like this or could the code work without it?
  3 Commenti
Aaron Smith
Aaron Smith il 4 Mag 2017
The files would likely require too much memory if i were to open them using both buttons (if i were to use one and then later use the other). I will almost certainly only using one of the buttons and then looking at plots of the data. So you think I should be ok to carry on in the way I am?
Adam
Adam il 4 Mag 2017
You might as well use a radio button in a button group if the options are truly mutually exclusive.
Then if the user really does want to select the other option you would just throw away everything from the previous one, freeing the memory too.
How to handle this type of behaviour in a GUI is very much down to the usage though - if it is just for you to test some things out then clearly it can be as basic as you want. If you are packaging it up and releasing it as a piece of software for paying clients to use then obviously the standards need to be a lot higher.

Risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by