I have a short GUI with input fields, radio buttons and push buttons:
function []=my_gui()S.fh = figure('units','pixels',... 'position',[100 300 600 500],... 'menubar','none',... 'name','my_gui',... 'numbertitle','off',... 'resize','off',... 'deletefcn','');S.field = uicontrol('style','edit',... 'unit','pix',... 'position',[10 450 50 30],... 'string','');S.radio = uicontrol('style','radiobutton',... 'unit','pix',... 'position',[25 410 120 30],... 'string','');S.button = uicontrol('style','push',... 'unit','pix',... 'position',[10 10 80 30],... 'string','Run');set(S.button,'callback',{@run_function,S});function [] = run_function(varargin)assignin('base','data_in',varargin);S = varargin{3}; % Get the structure.
my_field = str2double(get(S.field,'string'));my_radio=S.radio.Value;assignin('base','data_out',[my_field,my_radio]);
The GUI executes with no problems in R2015a, but when it is executed in R2012a the following message appears:
Attempt to reference field of non-structure array.Error in my_gui>run_function (line 28)my_radio=S.radio.Value;Error while evaluating uicontrol Callback
Looking at the 'data_in' and 'data_out' arrays in each version shows that in 2012a the uicontrol property in data_in{1} is no longer there. Can anyone advise on the issue, or if I require a workaround?
Best Answer