📄 zhang3.m
字号:
denc=sym2poly(n+d)
%绘制闭环bode图
w=logspace(-1,2)
[m1,p1]=bode(numc,denc,w)
subplot('position',[0.44,0.65,0.48,0.2])
amp=20*log10(m1)
semilogx(w,amp)
title('闭环bode图')
ylabel('幅值')
grid on
subplot('position',[0.44,0.4,0.48,0.18])
semilogx(w,p1)
xlabel('频率')
ylabel('相角')
grid on
%计算稳定裕量
sys=tf(numc,denc)
[Gm,Pm,Wcg,Wcp]=margin(sys)
set(handles.edit4,'string',Gm)
set(handles.edit5,'string',Pm)
set(handles.edit6,'string',Wcg)
set(handles.edit7,'string',Wcp)
set(handles.text5,'visible','on')
set(handles.text6,'visible','on')
set(handles.text7,'visible','on')
set(handles.text8,'visible','on')
set(handles.edit7,'visible','on')
set(handles.edit4,'visible','on')
set(handles.edit5,'visible','on')
set(handles.edit6,'visible','on')
set(handles.pushbutton1,'visible','on')
set(handles.pushbutton3,'visible','off')
% --- Executes on button press in radiobutton3.function radiobutton3_Callback(hObject, eventdata, handles)% hObject handle to radiobutton3 (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 radiobutton3
%选择单选按钮set(handles.radiobutton3,'value',1)
set(handles.radiobutton2,'value',0)
set(handles.radiobutton1,'value',0)
set(handles.radiobutton4,'value',0)
%获得输入值 z=str2num(get(handles.edit1,'string'))
p=str2num(get(handles.edit2,'string'))
k=str2num(get(handles.edit3,'string'))
sys=zpk(z,p,k)
subplot('position',[0.42,0.22,0.5,0.55])
%绘制nyquist曲线并标注
nyquist(sys)
grid on
title('nyquist曲线')
xlabel('实轴')
ylabel('虚轴')
set(handles.text5,'visible','off')
set(handles.text6,'visible','off')
set(handles.text7,'visible','off')
set(handles.text8,'visible','off')
set(handles.edit7,'visible','off')
set(handles.edit4,'visible','off')
set(handles.edit5,'visible','off')
set(handles.edit6,'visible','off')
set(handles.pushbutton3,'visible','on')
set(handles.pushbutton1,'visible','off')% --- Executes on button press in radiobutton4.function radiobutton4_Callback(hObject, eventdata, handles)% hObject handle to radiobutton4 (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 radiobutton4
%选择单选按钮set(handles.radiobutton4,'value',1)
set(handles.radiobutton2,'value',0)
set(handles.radiobutton3,'value',0)
set(handles.radiobutton1,'value',0)
%获得输入值 z=str2num(get(handles.edit1,'string'))
p=str2num(get(handles.edit2,'string'))
k=str2num(get(handles.edit3,'string'))
sys=zpk(z,p,k)
subplot('position',[0.42,0.22,0.5,0.55])
%绘制nichols曲线并标注
nichols(sys)
grid on
title('nichols曲线')
xlabel('开环相角 ')
ylabel('开环增益')
set(handles.text5,'visible','off')
set(handles.text6,'visible','off')
set(handles.text7,'visible','off')
set(handles.text8,'visible','off')
set(handles.edit7,'visible','off')
set(handles.edit4,'visible','off')
set(handles.edit5,'visible','off')
set(handles.edit6,'visible','off') set(handles.pushbutton3,'visible','off')
set(handles.pushbutton1,'visible','off')% --- Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
zyx9% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)close% --- Executes during object creation, after setting all properties.function edit4_CreateFcn(hObject, eventdata, handles)% hObject handle to edit4 (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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction edit4_Callback(hObject, eventdata, handles)% hObject handle to edit4 (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 edit4 as text% str2double(get(hObject,'String')) returns contents of edit4 as a double% --- Executes during object creation, after setting all properties.function edit5_CreateFcn(hObject, eventdata, handles)% hObject handle to edit5 (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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction edit5_Callback(hObject, eventdata, handles)% hObject handle to edit5 (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 edit5 as text% str2double(get(hObject,'String')) returns contents of edit5 as a double% --- Executes during object creation, after setting all properties.function edit6_CreateFcn(hObject, eventdata, handles)% hObject handle to edit6 (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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction edit6_Callback(hObject, eventdata, handles)% hObject handle to edit6 (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 edit6 as text% str2double(get(hObject,'String')) returns contents of edit6 as a double% --- Executes during object creation, after setting all properties.function edit7_CreateFcn(hObject, eventdata, handles)% hObject handle to edit7 (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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction edit7_Callback(hObject, eventdata, handles)% hObject handle to edit7 (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 edit7 as text% str2double(get(hObject,'String')) returns contents of edit7 as a double% --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
analysis2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -