Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
Curious
Posts:
1,699
Registered:
12/6/04
|
|
Re: Counter - problem with varargin
Posted:
Jan 17, 2013 9:54 AM
|
|
kagliostro <lucascarpantonio@gmail.com> wrote in message <bcbacdbd-f0e4-4b0c-9c16-3e6f748ee36c@googlegroups.com>... > Hi to everyone, I am new in this section and new to Matlab. > I am trying to make a GUI which would be able to calculate the ions concentration in solution given the initial concentrations and the binding constat. > > However, I am facing a problem with varargin. I order to simplify the problem I made a simpler case which gives the same error. I am using Matlab 2012 on Mac OS x 10.8. > > thanks in advance for your help > > CODE: > > function varargout = Example(varargin) > % EXAMPLE MATLAB code for Example.fig > % EXAMPLE, by itself, creates a new EXAMPLE or raises the existing > % singleton*. > % > % H = EXAMPLE returns the handle to a new EXAMPLE or the handle to > % the existing singleton*. > % > % EXAMPLE('CALLBACK',hObject,eventData,handles,...) calls the local > % function named CALLBACK in EXAMPLE.M with the given input arguments. > % > % EXAMPLE('Property','Value',...) creates a new EXAMPLE or raises the > % existing singleton*. Starting from the left, property value pairs are > % applied to the GUI before Example_OpeningFcn gets called. An > % unrecognized property name or invalid value makes property application > % stop. All inputs are passed to Example_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 Example > > % Last Modified by GUIDE v2.5 17-Jan-2013 14:56:48 > > % Begin initialization code - DO NOT EDIT > gui_Singleton = 1; > gui_State = struct('gui_Name', mfilename, ... > 'gui_Singleton', gui_Singleton, ... > 'gui_OpeningFcn', @Example_OpeningFcn, ... > 'gui_OutputFcn', @Example_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 Example is made visible. > function Example_OpeningFcn(hObject, ~, handles, varargin) > % This function has no final 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 Example (see VARARGIN) > > % Choose default command line final for Example > handles.output = hObject; > %handles.input = varargin{1}; > handles.counter = 0; > > % Update handles structure > guidata(hObject, handles); > > % UIWAIT makes Example wait for user response (see UIRESUME) > % uiwait(handles.figure1); > > > % --- Outputs from this function are returned to the command line. > function varargout = Example_OutputFcn(hObject, eventdata, handles) > % varargout cell array for returning final 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 final from handles structure > varargout{1} = handles.output; > > > % --- Executes on button press in Calculate. > function Calculate_Callback(hObject, eventdata, handles) > % hObject handle to Calculate (see GCBO) > % eventdata reserved - to be defined in a future version of MATLAB > % handles structure with handles and user data (see GUIDATA) > handles.counter = handl.counter +10; > set(handles.input,'String',num2str(handles.input)) > set(handles.final,'String',num2str(handles.input+handles.counter)) > guidata(hObject,handles); > > > function Input_Callback(hObject, eventdata, handles) > % hObject handle to Input (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 Input as text > % str2double(get(hObject,'String')) returns contents of Input as a double > > > % --- Executes during object creation, after setting all properties. > function Input_CreateFcn(hObject, eventdata, handles) > % hObject handle to Input (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 final_Callback(hObject, eventdata, handles) > % hObject handle to final (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 final as text > % str2double(get(hObject,'String')) returns contents of final as a double > > > % --- Executes during object creation, after setting all properties. > function final_CreateFcn(hObject, eventdata, handles) > % hObject handle to final (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
It would be helpful if you told us what the error message is.
|
|
|
|