From: Adam Chapman on 14 Jul 2010 04:05 Im making a GUI and have an error come up: "???Error using ==> set Invalid handle object. Error in ==> battery_gui>initialize_gui at 78 set(handles.batteryCapacity, 'String', 200)" I have pasted the piece of code that the error is coming from below : --------------------------------- function initialize_gui(fig_handle, handles, isconfirm) %Set up with values handles; set(handles.batteryCapacity, 'String', 200) set(handles.cellNum, 'String', 98); set(handles.maxDischarge, 'String',600); set(handles.maxRecharge, 'String', 400); handles.batteryCapacity=200; handles.cellNum=98; handles.maxDischarge=600; handles.maxRecharge=400; % Update handles structure guidata(handles.figure1, handles); ---------------------------------- I know the line "handles;" command looks silly, but strangely enough there is no error when the semicolon is not there, i.e. when handles is printed out in the command window. When the semicolon is used or that line is removed, the error occurs. Any help is greatly appreciated. Im new to GUIs so if there is a better way, please make me aware Many Thanks Adam
From: us on 14 Jul 2010 04:19 Adam Chapman <adamchapman1985(a)hotmail.co.uk> wrote in message <ab644f22-fb7a-417e-b1be-b4f62934980a(a)k39g2000yqb.googlegroups.com>... > Im making a GUI and have an error come up: > > "???Error using ==> set > Invalid handle object. > > Error in ==> battery_gui>initialize_gui at 78 > set(handles.batteryCapacity, 'String', 200)" > > I have pasted the piece of code that the error is coming from below : > > --------------------------------- > > function initialize_gui(fig_handle, handles, isconfirm) > %Set up with values > > handles; > > set(handles.batteryCapacity, 'String', 200) > set(handles.cellNum, 'String', 98); > set(handles.maxDischarge, 'String',600); > set(handles.maxRecharge, 'String', 400); > > handles.batteryCapacity=200; > handles.cellNum=98; > handles.maxDischarge=600; > handles.maxRecharge=400; > > % Update handles structure > guidata(handles.figure1, handles); > > ---------------------------------- > > > I know the line "handles;" command looks silly, but strangely enough > there is no error when the semicolon is not there, i.e. when handles > is printed out in the command window. When the semicolon is used or > that line is removed, the error occurs. > > > Any help is greatly appreciated. Im new to GUIs so if there is a > better way, please make me aware > > Many Thanks > Adam just to get the whole pic: can you show HOW you call the function(?)... us
From: Adam Chapman on 14 Jul 2010 04:32 On Jul 14, 9:19 am, "us " <u...(a)neurol.unizh.ch> wrote: > Adam Chapman <adamchapman1...(a)hotmail.co.uk> wrote in message <ab644f22-fb7a-417e-b1be-b4f629349...(a)k39g2000yqb.googlegroups.com>... > > Im making a GUI and have an error come up: > > > "???Error using ==> set > > Invalid handle object. > > > Error in ==> battery_gui>initialize_gui at 78 > > set(handles.batteryCapacity, 'String', 200)" > > > I have pasted the piece of code that the error is coming from below : > > > --------------------------------- > > > function initialize_gui(fig_handle, handles, isconfirm) > > %Set up with values > > > handles; > > > set(handles.batteryCapacity, 'String', 200) > > set(handles.cellNum, 'String', 98); > > set(handles.maxDischarge, 'String',600); > > set(handles.maxRecharge, 'String', 400); > > > handles.batteryCapacity=200; > > handles.cellNum=98; > > handles.maxDischarge=600; > > handles.maxRecharge=400; > > > % Update handles structure > > guidata(handles.figure1, handles); > > > ---------------------------------- > > > I know the line "handles;" command looks silly, but strangely enough > > there is no error when the semicolon is not there, i.e. when handles > > is printed out in the command window. When the semicolon is used or > > that line is removed, the error occurs. > > > Any help is greatly appreciated. Im new to GUIs so if there is a > > better way, please make me aware > > > Many Thanks > > Adam > > just to get the whole pic: can you show HOW you call the function(?)... > > us- Hide quoted text - > > - Show quoted text - I've actually just found out the problem. In the "set command I was defining a string but giving a number instead. changing set(handles.batteryCapacity, 'String', 200) to set(handles.batteryCapacity, 'String',' 200') solved that issue. Thanks
From: Adam Chapman on 14 Jul 2010 04:40 On Jul 14, 9:32 am, Adam Chapman <adamchapman1...(a)hotmail.co.uk> wrote: > On Jul 14, 9:19 am, "us " <u...(a)neurol.unizh.ch> wrote: > > > > > > > Adam Chapman <adamchapman1...(a)hotmail.co.uk> wrote in message <ab644f22-fb7a-417e-b1be-b4f629349...(a)k39g2000yqb.googlegroups.com>... > > > Im making a GUI and have an error come up: > > > > "???Error using ==> set > > > Invalid handle object. > > > > Error in ==> battery_gui>initialize_gui at 78 > > > set(handles.batteryCapacity, 'String', 200)" > > > > I have pasted the piece of code that the error is coming from below : > > > > --------------------------------- > > > > function initialize_gui(fig_handle, handles, isconfirm) > > > %Set up with values > > > > handles; > > > > set(handles.batteryCapacity, 'String', 200) > > > set(handles.cellNum, 'String', 98); > > > set(handles.maxDischarge, 'String',600); > > > set(handles.maxRecharge, 'String', 400); > > > > handles.batteryCapacity=200; > > > handles.cellNum=98; > > > handles.maxDischarge=600; > > > handles.maxRecharge=400; > > > > % Update handles structure > > > guidata(handles.figure1, handles); > > > > ---------------------------------- > > > > I know the line "handles;" command looks silly, but strangely enough > > > there is no error when the semicolon is not there, i.e. when handles > > > is printed out in the command window. When the semicolon is used or > > > that line is removed, the error occurs. > > > > Any help is greatly appreciated. Im new to GUIs so if there is a > > > better way, please make me aware > > > > Many Thanks > > > Adam > > > just to get the whole pic: can you show HOW you call the function(?)... > > > us- Hide quoted text - > > > - Show quoted text - > > I've actually just found out the problem. In the "set command I was > defining a string but giving a number instead. > > changing > set(handles.batteryCapacity, 'String', 200) > to > set(handles.batteryCapacity, 'String',' 200') > > solved that issue. > > Thanks- Hide quoted text - > > - Show quoted text - Actually it's not working now! If I take out the line handles=handles, I get the error again! my entire script is pasted below: function varargout = battery_gui(varargin) %clc % BATTERY_GUI M-file for battery_gui.fig % BATTERY_GUI, by itself, creates a new BATTERY_GUI or raises the existing % singleton*. % % H = BATTERY_GUI returns the handle to a new BATTERY_GUI or the handle to % the existing singleton*. % % BATTERY_GUI('CALLBACK',hObject,eventData,handles,...) calls the % local % function named CALLBACK in BATTERY_GUI.M with the given input arguments. % % BATTERY_GUI('Property','Value',...) creates a new BATTERY_GUI or raises the % existing singleton*. Starting from the left, property value pairs % are % applied to the GUI before battery_gui_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to battery_gui_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help battery_gui % Last Modified by GUIDE v2.5 14-Jul-2010 08:26:32 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @battery_gui_OpeningFcn, ... 'gui_OutputFcn', @battery_gui_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 battery_gui is made visible. function battery_gui_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to battery_gui (see VARARGIN) % Choose default command line output for battery_gui %1 handles.output = hObject; %2 % Update handles structure guidata(hObject, handles); %3 initialize_gui(hObject, handles, false); %4 % UIWAIT makes battery_gui wait for user response (see UIRESUME) % uiwait(handles.figure1); function initialize_gui(fig_handle, handles, isconfirm) %Set up with values 1 set(handles.batteryCapacity, 'String', '200') 2 set(handles.cellNum, 'String', '98'); 3 set(handles.maxDischarge, 'String','600'); 4 set(handles.maxRecharge, 'String', '400'); 5 handles.batteryCapacity=200; handles.cellNum=98; handles.maxDischarge=600; handles.maxRecharge=400; %handles %handles verbose debugging % Update handles structure guidata(handles.figure1, handles); % --- Outputs from this function are returned to the command line. function varargout = battery_gui_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; function batteryCapacity_Callback(hObject, eventdata, handles) % hObject handle to batteryCapacity (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of batteryCapacity as text % str2double(get(hObject,'String')) returns contents of batteryCapacity as a double handles.batteryCapacity = str2double(get(hObject, 'String')); %handles.metricdata.evMaxTorque = handles.evMaxTorque; guidata(hObject,handles) handles % --- Executes during object creation, after setting all properties. function batteryCapacity_CreateFcn(hObject, eventdata, handles) % hObject handle to batteryCapacity (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function maxDischarge_Callback(hObject, eventdata, handles) % hObject handle to maxDischarge (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of maxDischarge as text % str2double(get(hObject,'String')) returns contents of maxDischarge as a double % --- Executes during object creation, after setting all properties. function maxDischarge_CreateFcn(hObject, eventdata, handles) % hObject handle to maxDischarge (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. handles.maxDischarge = str2double(get(hObject, 'String')); if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in confirm. function confirm_Callback(hObject, eventdata, handles) % hObject handle to confirm (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) load_system('RREV_v4.mdl') %number of motors: set_param('RREV_v4/Electric Drive System/Kokam 200 Ah/Recharge/Ah Converter/Ah Capacity','Value',num2str(handles.batteryCapacity)) set_param('RREV_v4/Electric Drive System/Kokam 200 Ah/Recharge/Battery Current Limit','Gain',num2str(handles.maxRecharge)) %set_param('RREV_v4/Electric Drive System/UQM145 Motor x2/ Gain2','Gain',num2str(handles.evMotorNum)) %save model save_system function cellNum_Callback(hObject, eventdata, handles) % hObject handle to cellNum (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of cellNum as text % str2double(get(hObject,'String')) returns contents of cellNum as a double % --- Executes during object creation, after setting all properties. function cellNum_CreateFcn(hObject, eventdata, handles) % hObject handle to cellNum (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. handles.cellNum = str2double(get(hObject, 'String')); if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function maxRecharge_Callback(hObject, eventdata, handles) % hObject handle to maxDischarge (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of maxDischarge as text % str2double(get(hObject,'String')) returns contents of maxDischarge as a double % --- Executes during object creation, after setting all properties. function maxRecharge_CreateFcn(hObject, eventdata, handles) % hObject handle to maxDischarge (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. handles.maxRecharge = str2double(get(hObject, 'String')); if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
From: us on 14 Jul 2010 04:41 Adam Chapman > I've actually just found out the problem. In the "set command I was > defining a string but giving a number instead. > > changing > set(handles.batteryCapacity, 'String', 200) > to > set(handles.batteryCapacity, 'String',' 200') > > solved that issue. > > Thanks hmm... this is VERY intriguing(!)... why should this syntax problem cause this error message... > > "???Error using ==> set > > Invalid handle object. instead of the better known error ??? Error using ==> set -and- why should this error disappear with your tricky HANDLES(;) line... us
|
Next
|
Last
Pages: 1 2 3 4 Prev: Making some parts of image fully transparent Next: Extracting subvector between boundary |