function varargout = discrSyS(varargin) %Моделирование дискретных динамических систем gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @discrSyS_OpeningFcn, ... 'gui_OutputFcn', @discrSyS_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 discrSyS is made visible. function discrSyS_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 discrSyS (see VARARGIN) % Choose default command line output for discrSyS handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes discrSyS 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 = discrSyS_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); k = [t0(1):t0(2)]; n = length(k); x = zeros(n,length(x0)); x(1,:) = x0'; %решение методом итерации for j=2:n x(j,:) = feval(RHSNAME, x(j-1,:)')'; end; global flag1;%в отдельном ли окне? hold on; if get(handles.cbInd,'Value'), figure; flag1=1;else flag1=0;end; if get(handles.rb1,'value') %если задача одномерная hLog1=plot(k,x(:,1),'-'); legend('координата x1','Location','SouthOutside'); end if get(handles.rb2,'value') hLog1=plot(k,x(:,1),'-',k,x(:,2),'-.');%если задача двумерная legend('координата x1', 'координата x2','Location','SouthOutside'); end if get(handles.rb3,'value') %если задача трехмерная hLog1=plot(k,x(:,1),'-',k,x(:,2),'-.',k,x(:,3),'--'); legend('координата x1', 'координата x2','координата x3','Location','SouthOutside'); end if get(handles.rb4,'value') %если задача четырехмерная hLog1=plot(k,x(:,1),'-',k,x(:,2),'-.',k,x(:,3),'--',k,x(:,4),':'); legend('координата x1', 'координата x2','координата x3','координата x4','Location','SouthOutside'); end title('Дискретная во времени система'); % Кнопка Очистить должна стать доступной 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) % hObject handle to EdtB (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 EdtB as text % str2double(get(hObject,'String')) returns contents of EdtB as a double % --- 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) % hObject handle to EdtE (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 EdtE as text % str2double(get(hObject,'String')) returns contents of EdtE as a double % --- 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') phase2d; end if get(handles.rb3,'value') phase3d; end function EdtF_Callback(hObject, eventdata, handles) % hObject handle to EdtF (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 EdtF as text % str2double(get(hObject,'String')) returns contents of EdtF as a double % --- 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='lin2f'; [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'); function edit5_Callback(hObject, eventdata, handles) % hObject handle to EdtB (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 EdtB as text % str2double(get(hObject,'String')) returns contents of EdtB as a double % --- Executes during object creation, after setting all properties. function edit5_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 % --- Executes on button press in cbInd. function cbInd_Callback(hObject, eventdata, handles) % hObject handle to cbInd (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of cbInd