function varargout = contSyS(varargin) %%Моделирование динамических систем, непрерывных во времени gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @contSyS_OpeningFcn, ... 'gui_OutputFcn', @contSyS_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 % --- Executes just before contSyS is made visible. function contSyS_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 contSyS (see VARARGIN) % Choose default command line output for contSyS handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes contSyS wait for user response (see UIRESUME) % uiwait(handles.figure1); set(handles.axes1, 'Fontsize', 9); % --- Outputs from this function are returned to the command line. function varargout = contSyS_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; % Связь события CloseRequestFcn с подфункцией Close set(handles.output, 'CloseRequestFcn',{@Close,handles}) function Close(hObject,eventdata,handles)% Подфункция обработки события CloseRequestFcn окна приложения % Вывод модального диалогового окна с подтверждением закрытия q=questdlg('Закрыть приложение?','!!Информация!!','Да','Нет','Да'); % Проверка выбора пользователя if strcmp(q,'Да') % Пользователь подтвердил закрытие приложения, % удаляем окно приложения delete(handles.output); end % --- Executes on button press in btnPlot. function btnPlot_Callback(hObject, eventdata, handles) % hObject handle to btnPlot (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global RHSNAME;%имя функции RHSNAME=get(handles.EdtF,'string'); global x; ParStr = ['x0=', get(handles.EdtV,'String'), ';'];%начальный вектор % Выполнение строки, запись начального приближения в вектор х0 eval(ParStr); [r,c] = size(x0); if (r==1), x0 = x0'; end; %начальный и конечный момент моделирования ParStr = ['t0=', get(handles.EdtB,'String'), ';']; % Выполнение строки, запись начального приближения в вектор t0 eval(ParStr); options = odeset('RelTol',1e-4); %решение дифференциального уравнения методом Рунге-Кутты [t,x] = ode45(@RHSpatch, t0 ,x0,options); global flag1; %в отдельном ли окне? hold on; if get(handles.cbInd,'Value'), figure; flag1=1;else flag1=0;end; if get(handles.rb2,'value') %если задача двумерная hLog=plot(t,x(:,1),'-',t,x(:,2),'-.'); legend('координата x1', 'координата x2','Location','SouthOutside'); end if get(handles.rb3,'value') %если задача трехмерная hLog=plot(t,x(:,1),'-',t,x(:,2),'-.',t,x(:,3),'-.'); legend('координата x1', 'координата x2','координата x3','Location','SouthOutside'); end if get(handles.rb4,'value') %если задача четырехмерная hLog=plot(t,x(:,1),'-',t,x(:,2),'-.',t,x(:,3),'-.',t,x(:,4),'-.'); legend('координата x1', 'координата x2','координата x3','координата x4','Location','SouthOutside'); end title('Непрерывная во времени система'); grid on;%отображение сетки % Кнопка Очистить должна стать доступной set(handles.btnClear, 'Enable', 'on'); function EdtV_Callback(hObject, eventdata, handles) % hObject handle to EdtV (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 EdtV as text % str2double(get(hObject,'String')) returns contents of EdtV as a double % --- Executes during object creation, after setting all properties. function EdtV_CreateFcn(hObject, eventdata, handles) % hObject handle to EdtV (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 EdtB_Callback(hObject, eventdata, handles) % --- Executes during object creation, after setting all properties. function EdtB_CreateFcn(hObject, eventdata, handles) % hObject handle to EdtB (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 EdtE_Callback(hObject, eventdata, handles) % --- Executes during object creation, after setting all properties. function EdtE_CreateFcn(hObject, eventdata, handles) % hObject handle to EdtE (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 % --- Executes on button press in btnPhase. function btnPhase_Callback(hObject, eventdata, handles) % hObject handle to btnPhase (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if get(handles.rb2,'value') phase2c; end if get(handles.rb3,'value') phase3c; end function EdtF_Callback(hObject, eventdata, handles) % --- Executes during object creation, after setting all properties. function EdtF_CreateFcn(hObject, eventdata, handles) % hObject handle to EdtF (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 % --- Executes on button press in btnF. function btnF_Callback(hObject, eventdata, handles) % hObject handle to btnF (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global RHSNAME; RHSNAME='pendulum'; [flname, pname] = uigetfile('*.*','Выбор имени функции'); % получение имени и пути к файлу % Проверка, был ли открыт файл if flname ~= 0 % Образование полного имени файла RHSNAME = strrep(flname,'.m',''); end set(handles.EdtF,'string',RHSNAME); % --- Executes on button press in btnClear. function btnClear_Callback(hObject, eventdata, handles) % hObject handle to btnClear (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) cla ;% очистка осей % Кнопка Очистить должна стать недоступной после очистки осей set(hObject, 'Enable', 'off'); % Кнопка Построить должна стать доступной set(handles.btnClear, 'Enable', 'off'); % --- Executes on button press in cbInd. function cbInd_Callback(hObject, eventdata, handles)