增量谐波平衡法弧长法MATLAB实例代码
时间: 2023-07-24 16:48:09 浏览: 135
以下是增量谐波平衡法弧长法的MATLAB实例代码:
```matlab
clc;
clear;
close all;
% 参数设置
R = 1; % 电阻
L = 0.1; % 电感
C = 1e-6; % 电容
f = 50; % 电源频率
Vs = 220; % 电源电压
Vdc = 400; % 直流电压
delta_t = 1e-5; % 时间步长
t_sim = 0.1; % 模拟时间
omega = 2*pi*f; % 角频率
% 初始化变量
t = 0:delta_t:t_sim;
N = length(t);
v = zeros(1, N); % 电容电压
i = zeros(1, N); % 电感电流
Vc = Vdc/2; % 电容初始电压
delta_Vc = 0; % 电容电压增量
delta_i = 0; % 电感电流增量
delta_theta = 0; % 谐波相位增量
theta = 0; % 谐波相位
Vo = 0; % 输出电压
% 循环计算
for j = 1:N
% 增量谐波平衡法计算
delta_Vc = Vs*sin(omega*t(j)) - Vo - R*i(j) - Vc;
delta_i = (delta_Vc/L)*delta_t;
delta_theta = omega*delta_t + delta_i/Vdc;
theta = theta + delta_theta;
% 更新电路变量
i(j+1) = i(j) + delta_i;
Vc = Vc + delta_Vc;
v(j+1) = Vc - Vdc/2*sin(theta);
Vo = Vdc/2*sin(theta);
end
% 绘图
figure;
subplot(2,1,1);
plot(t, v(1:end-1), 'LineWidth', 2);
xlabel('时间 (s)');
ylabel('电容电压 (V)');
title('增量谐波平衡法弧长法模拟结果');
subplot(2,1,2);
plot(t, i(1:end-1), 'LineWidth', 2);
xlabel('时间 (s)');
ylabel('电感电流 (A)');
```
该代码实现了增量谐波平衡法弧长法对RLC电路的模拟,并绘制了电容电压和电感电流随时间变化的波形图。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)