I have a function which can be run in various different ways, depending on the state of 42 constants which are set at the top of the code. Up until now, if I want to run my function under different conditions, I simply open the MATLAB code and adjust the constant at the beginning of the code.
Fourty-two constants is a lot to keep track of, and I've found myself running experiments with certain switches accidentally left turned on. The obvious solution is to build a GUI, where my inputs can be seen visually in one place. The GUI would simply be a parameter setting window, with a big 'Go' button at the bottom which takes the inputs (all 42 of them!) and passes them into my main function.
I have come across GUIDE, which I have used to build a nice GUI. I have managed to get a button to launch my function, but I'm struggling to get the actual variables entered into text boxes and check box states to pass to the main function.
I understand it has something to do with 'Callbacks', but the documentation is unclear and seems to be more concerned with building GUIs in which the variables adjust the content of the current window.
As a basic example, I'm working with a check box. I know that when I click a check box, function checkbox1_Callback(hObject, eventdata, handles) executes. I have modified this function so that it returns a variable 'state', which is set during the function in the following way:
state = get(hObject,'Value')
This pops up a message saying that state has been changed, whenever I click the check box. Of course, as soon as this has happened, the function has ended and the variable destroyed. There doesn't seem to be any way of receiving the variable elsewhere. The .m code doesn't include a call to the checkbox1_Callback function anywhere, so I don't know where I can receive the input.
I had hoped I could just call the checkbox1_Callback function at the time of clicking the 'Go' button, but I don't know what arguments to pass to the callback.
Clearly I'm missing something fundamental here, but the documentation doesn't make this easy! Any pointers would be appreciated.