用matlab画脉冲系统非脉冲点及脉冲点的状态轨迹图
时间: 2023-08-12 16:03:19 浏览: 51
这里提供一种可能的实现方法,假设给定的脉冲系统非脉冲点和脉冲点的状态方程为:
x'(t) = f(x(t), u(t))
其中,x(t) 是系统的状态向量,u(t) 是系统的输入信号。对于非脉冲点,输入信号 u(t) 是连续时间函数,而对于脉冲点,输入信号是离散时间函数。
首先,我们需要定义系统的状态方程 f(x(t), u(t)),以及系统的初始状态 x0 和仿真时间范围 tspan:
```
% 定义系统的状态方程
function dx = state_eq(x, u)
dx = cos(x) + u;
% 定义系统的初始状态
x0 = 0;
% 定义仿真时间范围
tspan = [0 10];
```
接着,我们需要定义非脉冲点的输入信号函数 u(t),这里假设输入信号为一个正弦波:
```
% 定义非脉冲点的输入信号函数
function u = input_func(t)
u = sin(t);
```
然后,我们使用 ode45 函数求解系统的状态轨迹:
```
% 求解非脉冲点的状态轨迹
[t, x] = ode45(@(t, x) state_eq(x, input_func(t)), tspan, x0);
```
最后,我们可以使用 plot 函数画出系统的状态轨迹图:
```
% 画出非脉冲点的状态轨迹图
figure;
plot(t, x);
xlabel('时间');
ylabel('状态');
title('非脉冲点的状态轨迹图');
```
对于脉冲点,输入信号是离散时间函数,我们可以使用 MATLAB 中的 discrete 函数生成离散时间信号,并在仿真过程中根据脉冲时刻更新输入信号:
```
% 定义脉冲点的输入信号函数
function u = input_func(t, pulse_time)
u = zeros(size(t));
for i = 1:length(pulse_time)
u(t >= pulse_time(i)) = 1;
end
```
然后,在仿真过程中,我们需要指定脉冲时刻 pulse_time,并在 ode45 求解过程中根据脉冲时刻更新输入信号:
```
% 定义脉冲时刻
pulse_time = [1 3 5 7];
% 求解脉冲点的状态轨迹
[t, x] = ode45(@(t, x) state_eq(x, input_func(t, pulse_time)), tspan, x0);
```
最后,我们可以使用 stem 函数画出系统的状态轨迹图,其中蓝色的点表示脉冲时刻:
```
% 画出脉冲点的状态轨迹图
figure;
stem(pulse_time, ones(size(pulse_time)), 'b', 'filled');
hold on;
plot(t, x);
xlabel('时间');
ylabel('状态');
title('脉冲点的状态轨迹图');
```
相关推荐
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.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)