利用实验原理所给函数,编写matlab程序,完成实验内容3
时间: 2024-11-13 15:25:32 浏览: 30
为了完成实验内容3中的任务,可以使用MATLAB中的`rlocus`和其他相关函数来绘制根轨迹,并确定满足不同超调量要求的开环增益 \( K \) 范围。以下是具体的MATLAB代码示例:
### 实验内容3:单位负反馈系统,开环传递函数为 \( G(s) = \frac{K}{(s+4)(s+6)} \)
#### (1)绘制根轨迹
```matlab
% 定义开环传递函数
num = [1]; % 分子多项式系数
den = conv([1 4], [1 6]); % 分母多项式系数
% 绘制根轨迹
figure;
rlocus(num, den);
title('Root Locus for G(s) = K / ((s+4)(s+6))');
xlabel('Real Axis');
ylabel('Imaginary Axis');
grid on;
% 添加阻尼比线
zeta = [0.707, 0.5];
wn = 10; % 自然频率(任意值)
sgrid(zeta, wn);
```
#### (2)确定满足不同超调量要求的开环增益 \( K \) 范围
```matlab
% 计算不同超调量对应的阻尼比
zeta_16p3 = -log(0.163) / sqrt(pi^2 + log(0.163)^2); % 16.3%
zeta_4p3 = -log(0.043) / sqrt(pi^2 + log(0.043)^2); % 4.3%
zeta_0p43 = -log(0.0043) / sqrt(pi^2 + log(0.0043)^2); % 0.43%
% 使用 rlocfind 函数找到对应阻尼比的增益
[K_16p3, poles_16p3] = rlocfind(num, den, zeta_16p3);
[K_4p3, poles_4p3] = rlocfind(num, den, zeta_4p3);
[K_0p43, poles_0p43] = rlocfind(num, den, zeta_0p43);
% 输出结果
disp(['For 16.3% overshoot, the range of K is: ', num2str(K_16p3)]);
disp(['For 4.3% overshoot, the range of K is: ', num2str(K_4p3)]);
disp(['For 0.43% overshoot, the range of K is: ', num2str(K_0p43)]);
```
#### (3)绘制不同超调量下的阶跃响应曲线
```matlab
% 定义闭环传递函数
sys_16p3 = feedback(tf(K_16p3 * num, den), 1);
sys_4p3 = feedback(tf(K_4p3 * num, den), 1);
sys_0p43 = feedback(tf(K_0p43 * num, den), 1);
% 绘制阶跃响应
figure;
step(sys_16p3, 'b', sys_4p3, 'r', sys_0p43, 'g');
legend('16.3% Overshoot', '4.3% Overshoot', '0.43% Overshoot');
title('Step Response for Different Overshoot Requirements');
xlabel('Time (s)');
ylabel('Response');
grid on;
```
### 运行步骤
1. 将上述代码复制到MATLAB脚本文件中。
2. 在MATLAB环境中运行该脚本文件。
3. 根据提示输入或选择相应的数据点以获取特定的增益值。
以上代码将帮助你完成实验内容3中的所有任务,包括绘制根轨迹、确定满足不同超调量要求的开环增益范围以及绘制相应的阶跃响应曲线。
阅读全文
相关推荐


















