MATLAB: How can i update the edit box output in GUI

editboxguihandlesMATLAB

i have attached the full code of a simple IDMT device setting calculator, it is possible for the user to select device number 1 to 6 and each device has seven parameters, all user data is saved in a matrix. the program works fine except for i wish the edit box output data to update and display the correct matrix data when the device number is changed.
on line 189 i am trying to write a value to an edit box, the value is arbitrary for the time being, each time i get 'invalid handle object'
thanks in anticipation, Nathan
function varargout = new(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @new_OpeningFcn, ...
'gui_OutputFcn', @new_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before new is made visible.
function new_OpeningFcn(hObject, eventdata, handles, varargin)
clc
handles.internal_data = zeros(7,6);
% Choose default command line output for new
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
function varargout = new_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function ct_Callback(hObject, eventdata, handles)
ct = str2double(get(hObject, 'String'));
if isnan(ct)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
b = get(handles.dev_sel, 'value')
handles.internal_data(1,b) = ct
handles.internal_data
% Save the new volume value





handles.ct = ct;
guidata(hObject,handles) %%inputs
function ct_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function plug_Callback(hObject, eventdata, handles)
plug = str2double(get(hObject, 'String'));
if isnan(plug)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
b = get(handles.dev_sel, 'value')
handles.internal_data(2,b) = plug
handles.internal_data
% Save the new volume value
handles.plug = plug;
guidata(hObject,handles)
function plug_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function time_Callback(hObject, eventdata, handles)
time = str2double(get(hObject, 'String'));
if isnan(time)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
b = get(handles.dev_sel, 'value')
handles.internal_data(3,b) = time
handles.internal_data
% Save the new volume value
handles.time = time;
guidata(hObject,handles)
function time_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function vref_Callback(hObject, eventdata, handles)
vref = str2double(get(hObject, 'String'));
if isnan(vref)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
b = get(handles.dev_sel, 'value')
handles.internal_data(4,b) = vref
handles.internal_data
% Save the new volume value
handles.vref = vref;
guidata(hObject,handles)
function vref_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function vprot_Callback(hObject, eventdata, handles)
vprot = str2double(get(hObject, 'String'));
if isnan(vprot)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
b = get(handles.dev_sel, 'value')
handles.internal_data(5,b) = vprot
handles.internal_data
% Save the new volume value
handles.vprot = vprot;
guidata(hObject,handles)
function vprot_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function para_Callback(hObject, eventdata, handles)
para = str2double(get(hObject, 'String'));
if isnan(para)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
b = get(handles.dev_sel, 'value')
handles.internal_data(6,b) = para
handles.internal_data
% Save the new volume value
handles.para = para;
guidata(hObject,handles)
function para_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function listbox1_Callback(hObject, eventdata, handles) %%listbox inputs
b = get(handles.dev_sel, 'value')
a = get(handles.listbox1, 'value')
handles.internal_data(7,b) = a
handles.internal_data
% Save the new listbox value
guidata(hObject,handles)
function listbox1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function dev_sel_Callback(hObject, eventdata, handles)
b = 1 %get(handles.dev_sel, 'value')
a = num2str (7) %(handles.internal_data(1,b))
handles
set(handles.ct, 'String', a) ;
function dev_sel_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes on button press in calculate.
function calculate_Callback(hObject, eventdata, handles)
data_Voltage_ratio = zeros(1,6)
data_coeff = zeros(1,6)
trip_time = zeros(6,12)
fault_mag_series = [1.2, 2,3,4,5,6,7,8,9,10,20];
extremely = [80 , 2 ]; %scalar , exp
very = [13.5, 1 ];
standard = [0.14, 0.02];
long_time = [120 , 1 ];
x = 1 % repeated for each device
while x < 7
data_Voltage_ratio(x) = handles.internal_data(5,x) / handles.internal_data(4,x); % v/r = vprot / vref
data_Voltage_ratio(isnan(data_Voltage_ratio))=0; % replace nan with zero
data_coeff(x) = handles.internal_data(6,x) * handles.internal_data(2,x); % coeff = para * plug
m=1;
while m<12
fault_current_PU(x,m) = data_coeff(x) * fault_mag_series(m); % populates fault current values
fault_current_corrected(x,m) = fault_current_PU(x,m)* handles.internal_data(1,x) * data_Voltage_ratio(x) /1000;
if handles.internal_data(7,x) == 2
trip_time(x,m) = (extremely(1)*handles.internal_data(3,x)) / (((fault_current_PU(x,m) / (handles.internal_data(2,x) * handles.internal_data(6,x)))^extremely(2))-1)
elseif handles.internal_data(7,x) == 3
trip_time(x,m) = (very(1)*handles.internal_data(3,x)) / (((fault_current_PU(x,m) / (handles.internal_data(2,x) * handles.internal_data(6,x)))^very(2))-1)
elseif handles.internal_data(7,x) == 4
trip_time(x,m) = (standard(1)*handles.internal_data(3,x)) / (((fault_current_PU(x,m) / (handles.internal_data(2,x) * handles.internal_data(6,x)))^standard(2))-1)
elseif handles.internal_data(7,x) == 5
trip_time(x,m) = (long_time(1)*handles.internal_data(3,x)) / (((fault_current_PU(x,m) / (handles.internal_data(2,x) * handles.internal_data(6,x)))^long_time(2))-1)
end
m=m+1;
end
if handles.internal_data(7,x)~= 1
loglog (fault_current_corrected(x,1:11), trip_time(x,1:11))
grid on
hold on
title('Required Protection Settings');
xlabel('Fault Current (KA)')
ylabel('Time to Operate (Seconds)')
axis([0.01 100 0.1 100])
end
x=x+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Best Answer

i have used this method you suggest
set(handles.ct, 'String', num2str(handles.internal_data(1,b))
in the following form
function dev_sel_Callback(hObject, eventdata, handles)
b = get(handles.dev_sel, 'value')
c = (handles.internal_data(1,b))
set(handles.ct, 'string', num2str(c))
which works perfectly!!
thank you all very much