📄 zyx10.m
字号:
function varargout = zyx10(varargin)
% ZYX10 M-file for zyx10.fig
% ZYX10, by itself, creates a new ZYX10 or raises the existing
% singleton*.
%
% H = ZYX10 returns the handle to a new ZYX10 or the handle to
% the existing singleton*.
%
% ZYX10('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ZYX10.M with the given input arguments.
%
% ZYX10('Property','Value',...) creates a new ZYX10 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before zyx10_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to zyx10_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 zyx10
% Last Modified by GUIDE v2.5 08-Jun-2005 11:35:49
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @zyx10_OpeningFcn, ...
'gui_OutputFcn', @zyx10_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 zyx10 is made visible.
function zyx10_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 zyx10 (see VARARGIN)
% Choose default command line output for zyx10
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes zyx10 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = zyx10_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)
%设置当前窗口名
str='带渐近线的bode图'
set(gcf,'name',str,'numbertitle','off')
% Get default command line output from handles structure
varargout{1} = handles.output;
%将系统创建为tf对象
num=[1280 640]
den=[1 24.2 1605 320.2 16]
sys=tf(num,den)
%求系统零极点
[z,p,k]=zpkdata(sys,'v')
damp(z),damp(p)
abs(z),abs(p)
%确定频率范围
w=logspace(-2,3,100)';
[mag,phase]=bode(sys,w)
mag=reshape(mag,[100,1])
subplot('position',[0.18,0.22,0.62,0.62])
semilogx(w,20*log10(mag),'r')
%标注
title('幅频特性曲线')
xlabel('频率')
ylabel('幅值')
hold on
%各段斜率求得
lfg=dcgain(sys)
cf1_dB=20*log10(lfg)
plot([0.01,0.1],[cf1_dB;cf1_dB],'-')
cf2_dB=cf1_dB-40*log10(0.5/0.1)
plot([0.1,0.5],[cf1_dB,cf2_dB],'-')
cf3_dB=cf2_dB-20*log10(40/0.5)
plot([0.5,40],[cf2_dB,cf3_dB],'-')
end_dB=cf3_dB-60*log10(1000/40)
plot([40,1000],[cf3_dB;end_dB],'-')
hold off
%标注各段斜率
text(0.23,25,'-40db/dec')
text(15,-25,'-20db/dec')
text(25,-70,'-60db/dec')
%重新调整y轴
axis([0.01 1000 -100 40] )
% --- 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)close% --- 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)analysis1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -