⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 state_feedback_gui.m

📁 This software is developed to provide ease with controller design. For PID control, options are give
💻 M
📖 第 1 页 / 共 4 页
字号:
function rp_edit_Callback(hObject, eventdata, handles)
% hObject    handle to rp_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 rp_edit as text
%        str2double(get(hObject,'String')) returns contents of rp_edit as a double


% --- Executes during object creation, after setting all properties.
function rp_edit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to rp_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 selection change in PPC_popupmenu.
function PPC_popupmenu_Callback(hObject, eventdata, handles)
% hObject    handle to PPC_popupmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns PPC_popupmenu contents as cell array
%        contents{get(hObject,'Value')} returns selected item from PPC_popupmenu


% --- Executes during object creation, after setting all properties.
function PPC_popupmenu_CreateFcn(hObject, eventdata, handles)
% hObject    handle to PPC_popupmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu 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 File_Callback(hObject, eventdata, handles)
% hObject    handle to File (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function New_Callback(hObject, eventdata, handles)
% hObject    handle to New (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function mfile_Callback(hObject, eventdata, handles)
% hObject    handle to mfile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function GUI_Callback(hObject, eventdata, handles)
% hObject    handle to GUI (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Figure_Callback(hObject, eventdata, handles)
% hObject    handle to Figure (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Model_Callback(hObject, eventdata, handles)
% hObject    handle to Model (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Close_Callback(hObject, eventdata, handles)
% hObject    handle to Close (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

delete(handles.figure1) 


% --------------------------------------------------------------------
function SRWC_Callback(hObject, eventdata, handles)
% hObject    handle to SRWC (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 ======================
tf_pushbutton = get (handles.tf_radiob,'Value')
ss_pushbutton = get(handles.ss_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

%================= Error If both were not Selected ===================
if ss_pushbutton == get(handles.ss_radiob,'Min') && tf_pushbutton == get(handles.tf_radiob,'Min')
    errordlg('First Enter either "State Space" or "Transfer Function"')
end

%================= Implementing Transfer Function ====================
if tf_pushbutton == get(handles.tf_radiob,'Max') && ss_pushbutton == get(handles.ss_radiob,'Min')
    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 "Transfer Function"')
    end
    
%     global
    sys_tf = tf(num_dou,den_dou)
    figure
    step(sys_tf),title('Step Response Without Controller'),grid on
end

%================= Implementing State Space Model ====================

if ss_pushbutton == get(handles.ss_radiob,'Max') && tf_pushbutton == get(handles.tf_radiob,'Min')
    clc
    
    a= get(handles.A_edit,'String')
    a_dou = str2num(a)
    
    b= get(handles.B_edit,'String')
    b_dou = str2num(b)
    
    c= get(handles.C_edit,'String')
    c_dou = str2num(c)
    
    d= get(handles.D_edit,'String')
    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 = ss(a_dou,b_dou,c_dou,d_dou)
    figure
    step(sys_ss),title('Step Response Without Controller'),grid on
end

% --------------------------------------------------------------------
function Time_r_Callback(hObject, eventdata, handles)
% hObject    handle to Time_r (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function SRC_Callback(hObject, eventdata, handles)
% hObject    handle to SRC (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function IRWC_Callback(hObject, eventdata, handles)
% hObject    handle to IRWC (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 ======================
tf_pushbutton = get (handles.tf_radiob,'Value')
ss_pushbutton = get(handles.ss_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

%================= Error If both were not Selected ===================
if ss_pushbutton == get(handles.ss_radiob,'Min') && tf_pushbutton == get(handles.tf_radiob,'Min')
    errordlg('First Enter either "State Space" or "Transfer Function"')
end

%================= Implementing Transfer Function ====================
if tf_pushbutton == get(handles.tf_radiob,'Max') && ss_pushbutton == get(handles.ss_radiob,'Min')
    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 "Transfer Function"')
    end
    
%     global
    sys_tf = tf(num_dou,den_dou)
    figure
    Impulse(sys_tf),title('Impulse Response Without Controller'),grid on
end

%================= Implementing State Space Model ====================

if ss_pushbutton == get(handles.ss_radiob,'Max') && tf_pushbutton == get(handles.tf_radiob,'Min')
    clc
    
    a= get(handles.A_edit,'String')
    a_dou = str2num(a)
    
    b= get(handles.B_edit,'String')
    b_dou = str2num(b)
    
    c= get(handles.C_edit,'String')
    c_dou = str2num(c)
    
    d= get(handles.D_edit,'String')
    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 = ss(a_dou,b_dou,c_dou,d_dou)
    figure
    impulse(sys_ss),title('Impulse Response Without Controller'),grid on
end

% --------------------------------------------------------------------
function IRC_Callback(hObject, eventdata, handles)
% hObject    handle to IRC (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Frequency_r_Callback(hObject, eventdata, handles)
% hObject    handle to Frequency_r (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function BPWC_Callback(hObject, eventdata, handles)
% hObject    handle to BPWC (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 ======================
tf_pushbutton = get (handles.tf_radiob,'Value')
ss_pushbutton = get(handles.ss_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

%================= Error If both were not Selected ===================
if ss_pushbutton == get(handles.ss_radiob,'Min') && tf_pushbutton == get(handles.tf_radiob,'Min')
    errordlg('First Enter either "State Space" or "Transfer Function"')
end

%================= Implementing Transfer Function ====================
if tf_pushbutton == get(handles.tf_radiob,'Max') && ss_pushbutton == get(handles.ss_radiob,'Min')
    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 "Transfer Function"')
    end
    
%     global
    sys_tf = tf(num_dou,den_dou)
    figure
    bode(sys_tf),title('Bode Diagram Without Controller'),grid on
end

%================= Implementing State Space Model ====================

if ss_pushbutton == get(handles.ss_radiob,'Max') && tf_pushbutton == get(handles.tf_radiob,'Min')
    clc
    
    a= get(handles.A_edit,'String')
    a_dou = str2num(a)
    
    b= get(handles.B_edit,'String')
    b_dou = str2num(b)
    
    c= get(handles.C_edit,'String')
    c_dou = str2num(c)
    
    d= get(handles.D_edit,'String')
    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 = ss(a_dou,b_dou,c_dou,d_dou)
    figure
    bode(sys_ss),title('Bode Diagram Without Controller'),grid on
end
%=====================================================================

% --------------------------------------------------------------------
function NPWC_Callback(hObject, eventdata, handles)
% hObject    handle to NPWC (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 ======================
tf_pushbutton = get (handles.tf_radiob,'Value')
ss_pushbutton = get(handles.ss_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

%================= Error If both were not Selected ===================
if ss_pushbutton == get(handles.ss_radiob,'Min') && tf_pushbutton == get(handles.tf_radiob,'Min')
    errordlg('First Enter either "State Space" or "Transfer Function"')
end

%================= Implementing Transfer Function ====================
if tf_pushbutton == get(handles.tf_radiob,'Max') && ss_pushbutton == get(handles.ss_radiob,'Min')
    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 "Transfer Function"')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -