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

📄 state_feedback_gui.m

📁 This software is developed to provide ease with controller design. For PID control, options are give
💻 M
📖 第 1 页 / 共 4 页
字号:
    end
    
%     global
    sys_tf = tf(num_dou,den_dou)
    figure
    nyquist(sys_tf),title('Nyquist Plot 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
    nyquist(sys_ss),title('Nyquist Plot Without Controller'),grid on
end
%=====================================================================

% --------------------------------------------------------------------
function NCWC_Callback(hObject, eventdata, handles)
% hObject    handle to NCWC (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
    nichols(sys_tf),title('Nichols Chat 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
    nichols(sys_ss),title('Nichols Chat Without Controller'),grid on
end
%=====================================================================

% --------------------------------------------------------------------
function BPC_Callback(hObject, eventdata, handles)
% hObject    handle to BPC (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clc, 
value = get(handles.PPC_popupmenu,'Value')

if value == 1
     global sys_fd
     figure,bode(sys_fd),title('Bode Plot With State feedback Controller'),grid on
end

if value == 2
     global sys_fd_rp
     figure,bode(sys_fd_rp),title('Bode Plot With State feedback Controller'),grid on
end
% --------------------------------------------------------------------
function NPC_Callback(hObject, eventdata, handles)
% hObject    handle to NPC (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clc, 
value = get(handles.PPC_popupmenu,'Value')

if value == 1
     global sys_fd
     figure,nyquist(sys_fd),title('Nyquist Plot With State feedback Controller'),grid on
end

if value == 2
     global sys_fd_rp
     figure,nyquist(sys_fd_rp),title('Nyquist Plot With State feedback Controller'),grid on
end

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

clc, 
value = get(handles.PPC_popupmenu,'Value')

if value == 1
     global sys_fd
     figure,nichols(sys_fd),title('Nichols Chart With State feedback Controller'),grid on
end
% --------------------------------------------------------------------
function Root_l_Callback(hObject, eventdata, handles)
% hObject    handle to Root_l (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function RLWC_Callback(hObject, eventdata, handles)
% hObject    handle to RLWC (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
    rlocus(sys_tf),title('Root Locus Without Controller')
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
    rlocus(sys_ss),title('Root Locus Without Controller'),grid on
end
% --------------------------------------------------------------------
function RLC_Callback(hObject, eventdata, handles)
% hObject    handle to RLC (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clc, 
value = get(handles.PPC_popupmenu,'Value')

if value == 1
     global sys_fd
     figure,rlocus(sys_fd),title('Root Locus With State feedback Controller')
end



% --------------------------------------------------------------------
function PZMWC_Callback(hObject, eventdata, handles)
% hObject    handle to PZMWC (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
    pzmap(sys_tf),title('Pole Zero Map Without Controller')
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
    pzmap(sys_ss),title('Pole Zero Map Without Controller')
end
%=====================================================================

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

clc, 
value = get(handles.PPC_popupmenu,'Value')

if value == 1
     global sys_fd
     figure,pzmap(sys_fd),title('Pole-Zero Map With State feedback Controller')
end

clc, 
value = get(handles.PPC_popupmenu,'Value')

if value == 2
     global sys_fd_rp
     figure,pzmap(sys_fd_rp),title('Pole-Zero Map With State feedback Controller')
end



function BA_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 BA_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


⌨️ 快捷键说明

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