# 二、波特图分析仪原理仿真：一阶检测系统编程仿真题目要求

• 2、使用软件产生模拟正弦扫频信号（信号幅值和扫频间隔可在程序的GUI界面进行设置。且可以为设置线性扫频和对数扫频。此要求为选做）输入该检测系统。

• 3、将检测系统输出信号的幅值与输入信号的幅值相比较，得出幅值测量误差e。

• 4、将所有频率值（频率范围可自定，提示：不超过1000Hz)和对应的幅值测量误差e曲线绘制出来，横坐标为频率f，纵坐标为幅值测量误差。

• 5、 程序应该能够自动显示幅值误差ε<±5％对应的频率范围。

# 三、波特图分析仪原理仿真：一阶检测系统编程仿真实现步骤

## 3.3、在计算的回调函数中编写代码

``````function pushbutton_Ok_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_Ok (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
A = get(handles.maxValue, 'String');
minF = get(handles.minFrequency, 'String');
maxF = get(handles.maxFrequency, 'String');
T = get(handles.edit_time, 'String');
K = get(handles.edit_K, 'String');
e = get(handles.edit_e, 'String');

A = str2double(A);
minF = str2double(minF);
maxF = str2double(maxF);
T = str2double(T);
K = str2double(K);
E = str2double(e);

y = [];
for f = minF: 1: maxF
w = 2 * pi * f;
e = A - K / (1 + w^2*T^2)^0.5;
y = [y e];
end
x = minF: 1: maxF;
axes(handles.axes1);
plot(x, y, 'r');
grid on;
hold on;
``````

THE END

)">