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

📄 zhang2.m

📁 控制系统仿真中的频率特性的MATLAB源码
💻 M
📖 第 1 页 / 共 2 页
字号:
     %绘制闭环bode图
   w=logspace(-1,2);
    [m,p]=bode(numc,denc,w);
    subplot('position',[0.44,0.69,0.48,0.2]);
    semilogx(w,20*log10(m));
title('闭环bode图');
    ylabel('幅值') ;
    grid on;
    subplot('position',[0.44,0.42,0.48,0.2]);
    semilogx(w,p);
    xlabel('频率');
    ylabel('相角');
  
    grid on;
     %计算频域特性指标并显示
sys1=tf(numc,denc)
     [Gm,Pm,Wcg,Wcp]=margin(sys1)
  set(handles.edit5,'string',Gm)
  set(handles.edit6,'string',Pm)
  set(handles.edit7,'string',Wcg)
  set(handles.edit8,'string',Wcp)
  set(handles.edit5,'visible','on')
  set(handles.edit6,'visible','on')
  set(handles.edit7,'visible','on')
  set(handles.edit8,'visible','on')
  set(handles.text9,'visible','on')
  set(handles.text10,'visible','on')
  set(handles.text11,'visible','on')
  set(handles.text12,'visible','on')
  set(handles.pushbutton5,'visible','on')
set(handles.pushbutton8,'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.radiobutton1,'value',0)
set(handles.radiobutton2,'value',0)
set(handles.radiobutton4,'value',0)
%获得输入数值
  A=str2num(get(handles.edit1,'string'))
    B=str2num(get(handles.edit2,'string'))
    C=str2num(get(handles.edit3,'string'))
    D=str2num(get(handles.edit4,'string'))
    sys=ss(A,B,C,D)
     %绘制nyquist曲线
    subplot('position',[0.45,0.25,0.5,0.7])
    nyquist(sys)
    grid on
    title('nyquist曲线')
    xlabel('实轴')
    ylabel('虚轴')
  set(handles.edit5,'visible','off')
  set(handles.edit6,'visible','off')
  set(handles.edit7,'visible','off')
  set(handles.edit8,'visible','off')
  set(handles.text9,'visible','off')
  set(handles.text10,'visible','off')
  set(handles.text11,'visible','off')
  set(handles.text12,'visible','off')
  set(handles.pushbutton8,'visible','on')
set(handles.pushbutton5,'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.radiobutton1,'value',0)
set(handles.radiobutton2,'value',0)
set(handles.radiobutton3,'value',0)%获得输入数值  A=str2num(get(handles.edit1,'string'))
    B=str2num(get(handles.edit2,'string'))
    C=str2num(get(handles.edit3,'string'))
    D=str2num(get(handles.edit4,'string'))
    sys=ss(A,B,C,D)
     %绘制nichols曲线
    subplot('position',[0.45,0.22,0.5,0.65])
  nichols(sys)
   grid on
   title('nichols曲线')
   xlabel('开环相角 ')
   ylabel('开环增益')
  set(handles.edit5,'visible','off')
  set(handles.edit6,'visible','off')
  set(handles.edit7,'visible','off')
  set(handles.edit8,'visible','off')
  set(handles.text9,'visible','off')
  set(handles.text10,'visible','off')
  set(handles.text11,'visible','off')
  set(handles.text12,'visible','off')
set(handles.pushbutton5,'visible','off')
set(handles.pushbutton8,'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 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 during object creation, after setting all properties.function edit8_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit8 (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 edit8_Callback(hObject, eventdata, handles)% hObject    handle to edit8 (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 edit8 as text%        str2double(get(hObject,'String')) returns contents of edit8 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)% --- Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton5 (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 pushbutton6.function pushbutton6_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton6 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)close% --- Executes on button press in pushbutton8.function pushbutton8_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton8 (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 + -