function varargout = untitled(varargin)
% UNTITLED MATLAB code for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_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 untitled
% Last Modified by GUIDE v2.5 23-Dec-2019 08:04:31
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_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 untitled is made visible.
function untitled_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 untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;
handles.x = 0;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_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;
% --- Executes on button press in Clear.
function Clear_Callback(hObject, eventdata, handles)
% hObject handle to Clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
try
delete(allchild(handles.axes2))
delete(allchild(handles.axes1))
end
% --- Executes on key press with focus on Clear and none of its controls.
function Clear_KeyPressFcn(hObject, eventdata, handles) % 检测键盘的回车键
% hObject handle to Clear (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
if double(get(gcf,'CurrentCharacter')) == ''
Load_Callback(hObject, eventdata, handles)
end
% --- Executes during object creation, after setting all properties.
function figure1_CreateFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
%--------------------给GUI 添背景---------------------%
% ha=axes('units','normalized','pos',[0 0 1 1]);
% uistack(ha,'bottom');
% ii=imread('雪1.jpg');
% image(ii);
% colormap gray
% set(ha,'handlevisibility','off','visible','on'); % 没有这句话 会导致鼠标滚动 然后背景放大
% set(gcf,'WindowStyle','modal') % 对话框形式
%-----------------------------------------------------------%
% A = imread('雪1.jpg');
% % %set(handles.Clear,'Cdata',A) % 给按钮添加图片
% image(A);
% figure('menubar','figure1');
% --- 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 on button press in Sanjiaobo_1.
function Sanjiaobo_1_Callback(hObject, eventdata, handles)
% hObject handle to Sanjiaobo_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Kp = str2double(get(handles.K_P,'String'));
% Ki = str2double(get(handles.K_I,'String'));
% Kd = str2double(get(handles.K_P,'String'));
% Hint: get(hObject,'Value') returns toggle state of Sanjiaobo_1
% --- Executes on button press in Juchibo_1.
function Juchibo_1_Callback(hObject, eventdata, handles)
% hObject handle to Juchibo_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Kp = str2double(get(handles.K_P,'String'));
% Ki = str2double(get(handles.K_I,'String'));
% Kd = str2double(get(handles.K_P,'String'));
% Hint: get(hObject,'Value') returns toggle state of Juchibo_1
% --- Executes on button press in Zhengxianbo_1.
function Zhengxianbo_1_Callback(hObject, eventdata, handles)
% hObject handle to Zhengxianbo_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Kp = str2double(get(handles.K_P,'String'));
% Ki = str2double(get(handles.K_I,'String'));
% Kd = str2double(get(handles.K_P,'String'));
% Hint: get(hObject,'Value') returns toggle state of Zhengxianbo_1
%----------------------切换不写在这里面则不切换成功-----------------------------%
% --- Executes when selected object is changed in options.
function options_SelectionChangedFcn(hObject, eventdata, handles)
% hObject handle to the selected object in options
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Kp = str2double(get(handles.K_P,'String'));
Ki = str2double(get(handles.K_I,'String'));
Kd = str2double(get(handles.K_D,'String'));
nums = str2num(get(handles.nums,'String'));
dens = str2num(get(handles.dens,'String'));
S_1 = get(handles.Sanjiaobo_1,'Value');
S_2 = get(handles.Juchibo_1,'Value');
S_3 = get(handles.Zhengxianbo_1,'Value');
axes(handles.axes2);
if S_1 == 1
out = PIDcontrol(1,Kp,Ki,Kd,nums,dens);
elseif S_2 == 1
out = PIDcontrol(2,Kp,Ki,Kd,nums,dens);
elseif S_3 == 1
out = PIDcontrol(3,Kp,Ki,Kd,nums,dens);
end
function K_P_Callback(hObject, eventdata, handles)
% hObject handle to K_P (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 K_P as text
% str2double(get(hObject,'String')) returns contents of K_P as a double
% --- Executes during object creation, after setting all properties.
function K_P_CreateFcn(hObject, eventdata, handles)
% hObject handle to K_P (see GCBO)
% eventdata reserved - to be defined in a f