Info

此问题已关闭。 请重新打开它进行编辑或回答。

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

1 次查看(过去 30 天)
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 个评论
Aaron Smith
Aaron Smith 2017-5-4
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 2017-5-4
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.

回答(0 个)

此问题已关闭。

产品

Community Treasure Hunt

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

Start Hunting!

Translated by