Hi all,
I'm having an issue building a programmatic GUI for a small app I'm currently working on. The GUI has a number of sliders and edit boxes to modify the parameters of an aircraft which can then be further analysed. I'm trying to set the default values of those sliders and edit boxes with data from a .mat configuration file I have created separately.
I know that it's possible to set the default values of these graphics objects when you write the code to create them (ie uicontrol('Style', 'slider', 'Value', 50)), but the numbers will require some processing and given I have 40+ controls in total, it's a little impractical to do it all manually. What I'd like to do (ideally) is have a function that executes when the GUI is created that sets all the default values of all the controls then. I already have a way of updating all the parameters in an easy and scalable way but am struggling to find somewhere to execute the code. My method relies on getting the list of uicontrol objects using 'findobj' and specifying edit and slider objects, then looping through that list of returned objects and matching the tags to variable names in the configuration file. I've tested this and it seems to work well.
I thought that adding this code to the 'CreateFcn' of the GUI figure would work perfectly, as the description says this function is executed 'just before the figure is made visible' but when I run my code in this opening function 'findobj' doesn't return a list of values, just a 0x0 array. I'm guessing this is because the createFcn is executing earlier than I expected when the uicontrols haven't actually been created.
Does anyone have any ideas on how I could make this work?
Many thanks for any help,
Chris
Best Answer