From: Adam Chapman on 29 Jun 2010 09:45 Hi, Im making a GUI with a dropdown menu to select a data file, then using buttons to run some calculations on that data. The problem is that the button callbacks can't find the variable set in the menu callback. My menu callback is defined with: function popup_menu_Callback(source,eventdata) str = get(source, 'String'); val = get(source,'Value'); % Set current data to the selected data set. switch str{val}; case 'EPA Inspection and Maintenance (IM240)' % User selects IM240 cycle. cycledef = 'im240col.txt'; case 'EPA Urban Dynamometer Driving Schedule (UDDS)' cycledef = 'uddscol.txt'; case 'Federal Test Procedure(FTP)' cycledef = 'ftpcol.txt'; case 'Highway Fuel Economy Driving Schedule (HWFET)' cycledef = 'hwycol.txt'; case 'The New York City Cycle (NYCC)' cycledef = 'nycccol.txt'; case 'US06 "Supplemental FTP"' cycledef = 'us06col.txt'; case 'SC03 Air Conditioning "Supplemental FTP"' cycledef = 'sc03col.txt'; case 'EPA Heavy Duty Urban Dynamometer Driving Schedule' cycledef = 'huddscol.txt'; end end Now if I try so define the function with something like: cycledef=function popup_menu_Callback(source,eventdata) it says "ERROR: invalid use of FUNCTION keyword will be ignored". An example of one of my button callbacks is: function mode1button_Callback(source,eventdata) % run calculations for mode 1: Mode1([cd '\drivecycles\' cycledef]) end In summarry the button callback function doesn't have access to the variable "cycledef", which is set in the menu callback but not output from the menu callback. How can I make the variable "cycledef" available to the button callback function?
From: Matt Fig on 29 Jun 2010 10:11 You need to store the data somewhere if you are not using nested functions. See the GUIDATA function for example.
|
Pages: 1 Prev: Deriving mean of each row in a matrix, disregarding zeros Next: Quick Histogram Question |