Hello,
Je cherche à enregistrer des valeurs entrées dans un gui pour ensuite les réutiliser pour faire un calcul. C'est à dire que chaque case remplie doit m'enregistrer des nombres, qui seront réutiliés dans une fonction appelée par le bouton.
Voilà le code, j'aimerai savoir comment la fonctiondoit récuperer les valeurs des cases (N,L,lambda....)Code:function simulation_Callback(hObject, eventdata, handles)
(Je ne veux rien afficher pour l'instant, juste faire des calculs à l'aide des valeurs inscrites
MerciCode:function varargout = it(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @it_OpeningFcn, ... 'gui_OutputFcn', @it_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 function it_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles); function varargout = it_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output; % --- Executes on button press in pushbutton1. function simulation_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) dX=H/N; %voilà les calculs à effectuer dY=L/N; lux=0; h=l/nb; Y=[zeros(1,N-1)]; X=[zeros(1,N-1)]; y1=[0.05 zeros(1,nb-1)]; ty1=[zeros(1,nb)]; ty2=[zeros(1,nb)]; a=[zeros(1,nb)]; b=[zeros(1,nb)]; I=[zeros(N,N)]; u=[zeros(N-1,N-1)]; v=[zeros(N-1,N-1)]; x2=x1+dx; % --- Executes on button press in reset. function reset_Callback(hObject, eventdata, handles) initialize_gui(gcbf, handles, true);function initialize_gui(fig_handle, handles, isreset) if isfield(handles, 'metricdata') && ~isreset return; end set(handles.N, 'String', ''); set(handles.L, 'String', ''); set(handles.nb, 'String', ''); set(handles.lambda, 'String', ''); set(handles.z, 'String', ''); set(handles.H, 'String', ''); set(handles.x1, 'String', ''); set(handles.dx, 'String', ''); set(handles.dy, 'String', ''); set(handles.la, 'String', ''); set(handles.I0, 'String', ''); guidata(handles.figure1, handles); function N_Callback(hObject, eventdata, handles) %variables à récuperer input = str2num(get(hObject,'String')); function N_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function L_Callback(hObject, eventdata, handles) input = str2num(get(hObject,'String')); function L_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function z_Callback(hObject, eventdata, handles) input =str2num(get(hObject,'String')); if (isempty(input)) set(hObject,'String','0') end function z_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function H_Callback(hObject, eventdata, handles) input = str2num(get(hObject,'String')); function H_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function dx_Callback(hObject, eventdata, handles) input = str2num(get(hObject,'String')); function dx_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function dy_Callback(hObject, eventdata, handles) input = str2num(get(hObject,'String')); function dy_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function nb_Callback(hObject, eventdata, handles) input = str2num(get(hObject,'String')); function nb_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function la_Callback(hObject, eventdata, handles) input = str2num(get(hObject,'String')); function la_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function I0_Callback(hObject, eventdata, handles) input = str2num(get(hObject,'String')); function I0_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function lambda_Callback(hObject, eventdata, handles) input = str2num(get(hObject,'String')); function lambda_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function x1_Callback(hObject, eventdata, handles) input = str2num(get(hObject,'String')); function x1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end; % --- Executes during object creation, after setting all properties. function axes1_CreateFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: place code in OpeningFcn to populate axes1 % --- Executes during object deletion, before destroying properties. function axes1_DeleteFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on mouse press over axes background. function axes1_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
-----