Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 求解方程组以获得期望阶跃响应_Matlab_Plot_Equation_Ode45 - Fatal编程技术网

Matlab 求解方程组以获得期望阶跃响应

Matlab 求解方程组以获得期望阶跃响应,matlab,plot,equation,ode45,Matlab,Plot,Equation,Ode45,我需要获得以下方程式中的a、b和c值,以便系统的阶跃响应与下图匹配 x_dot = a*x + b+u; y = c*x; clc; close all; clear all; a=-0.5; b=0.2; c=-0.00000001; tspan = [0:0.01:12]; f = @(t,x) [a*x(1)+b*x(2); c*x(1)]; [t, xa] = ode45(f,tspan,[0,10]); plot(t,xa); hold on plot(t,4) 其中x_

我需要获得以下方程式中的a、b和c值,以便系统的阶跃响应与下图匹配

x_dot = a*x + b+u;
y = c*x;
clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
其中x_dot是x的一阶导数

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
我一直试图通过Matlab实现这一点,到目前为止,我已经实现了以下目标,仅使用a、b和c的任意值进行测试:

clc;
close all;
clear all;

a=1;
b=2;
c=3;

tspan = [0:0.01:12];

x_dot = a*x+b*xu;
x = (a*x^2)/2 + b*u*x;
y = c*x;

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,0]);

plot(t,xa(:,1));
clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)

正如已经暗示的那样,这听起来确实像是一个参数估计问题。您希望最小化使用ode建模的结果与图形中的值之间的误差(将三个参数a、b和c与数据相匹配)

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
第一步是编写一个误差函数,该函数获取ode输出值,并比较其与数据值的接近程度(例如,最小二乘误差和)

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
然后,您必须搜索a、b、c值的范围(这可能是一个较大的搜索空间),并选择一组(a、b、c),以最小化错误函数(即尽可能接近图形)

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
存在许多搜索/优化策略(…例如遗传算法等)

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
请注意,参数是实数元素(包括负值和非常大或非常小的值),较大的搜索空间通常使这些问题难以解决。
此外,我认为你必须注意初始条件,例如[0,0]似乎不会产生有趣的结果。(尝试a=-0.5,b=0.2和c=-0.00000001,IC为[0,10],如下所示)

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
这里10是绿线的起点,蓝线从0开始。我还要注意的是IC会改变结果。。所以对于给定的IC,有很多可能的解决方案

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
看起来很有趣。。祝你好运

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)

正如已经暗示的,这听起来确实像是一个参数估计问题。您希望最小化使用ode建模的结果与图形中的值之间的误差(将三个参数a、b和c与数据相匹配)

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
第一步是编写一个误差函数,该函数获取ode输出值,并比较其与数据值的接近程度(例如,最小二乘误差和)

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
然后,您必须搜索a、b、c值的范围(这可能是一个较大的搜索空间),并选择一组(a、b、c),以最小化错误函数(即尽可能接近图形)

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
存在许多搜索/优化策略(…例如遗传算法等)

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
请注意,参数是实数元素(包括负值和非常大或非常小的值),较大的搜索空间通常使这些问题难以解决。
此外,我认为你必须注意初始条件,例如[0,0]似乎不会产生有趣的结果。(尝试a=-0.5,b=0.2和c=-0.00000001,IC为[0,10],如下所示)

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
这里10是绿线的起点,蓝线从0开始。我还要注意的是IC会改变结果。。所以对于给定的IC,有很多可能的解决方案

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)
看起来很有趣。。祝你好运

clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)

您有系统识别工具箱吗?如果是,请看一看。或者,如果您有优化工具箱,您可以使用预测阶跃响应和所需阶跃响应之间的误差的最小平方差来创建成本函数,并通过调整参数来尝试将其最小化。
y
(我假设代码中的
x(2)
)也应该是第一个代码块中的时间导数,以便在
ode45
调用中包含其右侧?什么是
u
,什么是
xu
(您发布的系统中没有)?您可以访问哪些信息来匹配图形:仅图形或初始坡度或终端值和坡度或其他信息?您有系统识别工具箱吗?如果是,请看一看。或者,如果您有优化工具箱,您可以使用预测阶跃响应和所需阶跃响应之间的误差的最小平方差来创建成本函数,并通过调整参数来尝试将其最小化。
y
(我假设代码中的
x(2)
)也应该是第一个代码块中的时间导数,以便在
ode45
调用中包含其右侧?什么是
u
,什么是
xu
(您发布的系统中没有)?您可以访问哪些信息来匹配图形:仅图形或初始坡度或终端值和坡度或其他信息?
clc;
close all;
clear all;

a=-0.5;
b=0.2;
c=-0.00000001;

tspan = [0:0.01:12];

f = @(t,x) [a*x(1)+b*x(2); c*x(1)];
[t, xa] = ode45(f,tspan,[0,10]);

plot(t,xa);
hold on 
plot(t,4)