📄 state_feedback_gui.m
字号:
function varargout = state_feedback_gui(varargin)
global sys_tf sys_ss sys_fd sys_fd_rp
global a_dou b_dou c_dou d_dou
% STATE_FEEDBACK_GUI M-file for state_feedback_gui.fig
% STATE_FEEDBACK_GUI, by itself, creates a new STATE_FEEDBACK_GUI or raises the existing
% singleton*.
%
% H = STATE_FEEDBACK_GUI returns the handle to a new STATE_FEEDBACK_GUI or the handle to
% the existing singleton*.
%
% STATE_FEEDBACK_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in STATE_FEEDBACK_GUI.M with the given input arguments.
%
% STATE_FEEDBACK_GUI('Property','Value',...) creates a new STATE_FEEDBACK_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before state_feedback_gui_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to state_feedback_gui_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 state_feedback_gui
% Last Modified by GUIDE v2.5 31-Jul-2008 12:27:40
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @state_feedback_gui_OpeningFcn, ...
'gui_OutputFcn', @state_feedback_gui_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 state_feedback_gui is made visible.
function state_feedback_gui_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 state_feedback_gui (see VARARGIN)
% Choose default command line output for state_feedback_gui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes state_feedback_gui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = state_feedback_gui_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 tf_pushb.
function tf_pushb_Callback(hObject, eventdata, handles)
% hObject handle to tf_pushb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%====================== Values from Radio Button ======================
ss_pushbutton = get (handles.ss_radiob,'Value');
tf_pushbutton = get (handles.tf_radiob,'Value');
%================= Error If both Options Selected ====================
if ss_pushbutton == get(handles.ss_radiob,'Max') && tf_pushbutton == get(handles.tf_radiob,'Max')
errordlg('Select One Option from "State Space" or "Transfer Function"');
end
%================= Implementing Transfer Function ====================
if tf_pushbutton == get(handles.tf_radiob,'Max')
clc;
num= get (handles.num_edit,'string');
num_dou = str2num(num);
den= get (handles.den_edit,'string');
den_dou = str2num(den);
%================= Error If Either Num or Den is empty ====================
if isempty(num_dou) || isempty(den_dou)
errordlg('Please enter in right format, For Example Num = [1 2] or Den = [1 2 3]');
end
global sys_tf
sys_tf = tf(num_dou,den_dou); % Transfer Function
%==========================================================================
% ord = order(sys_tf)
% if ord~= 2
% errordlg('Enter Second Order Systems (This software is designed only for second order system')
% end
%==========================================================================
%================= Error If Transfer Function Button is not selected =======
else
errordlg('Select "Transfer Function');
end
% --- Executes on button press in ss_pushb.
function ss_pushb_Callback(hObject, eventdata, handles)
% hObject handle to ss_pushb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%====================== Values from Radio Button ======================
ss_pushbutton = get (handles.ss_radiob,'Value');
tf_pushbutton = get (handles.tf_radiob,'Value');
%================= Error If both Options Selected ====================
if ss_pushbutton == get(handles.ss_radiob,'Max') && tf_pushbutton == get(handles.tf_radiob,'Max')
errordlg('Select One Option from "State Space" or "Transfer Function"');
end
%================= Implementing State Space Model ====================
if ss_pushbutton == get(handles.ss_radiob,'Max')
clc;
a= get(handles.A_edit,'String');
global a_dou
a_dou = str2num(a);
b= get(handles.B_edit,'String');
global b_dou
b_dou = str2num(b);
c= get(handles.C_edit,'String');
global c_dou
c_dou = str2num(c);
d= get(handles.D_edit,'String');
global d_dou
d_dou = str2num(d);
%================= Error If Either A,B,C or D is empty ==============
if isempty(a_dou) || isempty(b_dou) || isempty(c_dou) || isempty(d_dou)
errordlg('Please enter all A,B,C and D');
end
global sys_ss
sys_ss = ss(a_dou,b_dou,c_dou,d_dou); % State Space Model
%==========================================================================
% ord = order(sys_ss)
% if ord~= 2
% errordlg('Enter Second Order Systems (This software is designed only for second order system')
% end
%======================================================================
%====
%================= Error If State Space Button is not selected =======
else
errordlg('Select "State Space"');
end
%========================================================================
function B_edit_Callback(hObject, eventdata, handles)
% hObject handle to B_edit (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 B_edit as text
% str2double(get(hObject,'String')) returns contents of B_edit as a double
% --- Executes during object creation, after setting all properties.
function B_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to B_edit (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 A_edit_Callback(hObject, eventdata, handles)
% hObject handle to A_edit (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 A_edit as text
% str2double(get(hObject,'String')) returns contents of A_edit as a double
% --- Executes during object creation, after setting all properties.
function A_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to A_edit (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 C_edit_Callback(hObject, eventdata, handles)
% hObject handle to C_edit (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 C_edit as text
% str2double(get(hObject,'String')) returns contents of C_edit as a double
% --- Executes during object creation, after setting all properties.
function C_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to C_edit (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 D_edit_Callback(hObject, eventdata, handles)
% hObject handle to D_edit (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 D_edit as text
% str2double(get(hObject,'String')) returns contents of D_edit as a double
% --- Executes during object creation, after setting all properties.
function D_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to D_edit (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 tf_radiob.
function tf_radiob_Callback(hObject, eventdata, handles)
% hObject handle to tf_radiob (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 tf_radiob
% --- Executes on button press in ss_radiob.
function ss_radiob_Callback(hObject, eventdata, handles)
% hObject handle to ss_radiob (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 ss_radiob
function num_edit_Callback(hObject, eventdata, handles)
% hObject handle to num_edit (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 num_edit as text
% str2double(get(hObject,'String')) returns contents of num_edit as a double
% --- Executes during object creation, after setting all properties.
function num_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to num_edit (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 den_edit_Callback(hObject, eventdata, handles)
% hObject handle to den_edit (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 den_edit as text
% str2double(get(hObject,'String')) returns contents of den_edit as a double
% --- Executes during object creation, after setting all properties.
function den_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to den_edit (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 zeta_edit_Callback(hObject, eventdata, handles)
% hObject handle to zeta_edit (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 zeta_edit as text
% str2double(get(hObject,'String')) returns contents of zeta_edit as a double
% --- Executes during object creation, after setting all properties.
function zeta_edit_CreateFcn(hObject, eventdata, handles)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -