我正在努力寻找一种编写代码的方法,可以让我执行以下操作:
我有一个名为fy
的非线性ODE。
fy = g1*p1+g2*p2+g3*p3; % g1,g2,g3 are real-valued numbers and p1,p2,p3 are vectors
g1
,g2
和g3
是线性回归方法找到的常数。
g1 = 591.5121
g2 = 35.1352
g3 = 107.5798
向量p1
,p2
和p3
如下:(抱歉,我没有给出孔向量p1
,p2
和{ {1}}因为他们有 1500行:
p3
我正在解决[ p1 p2 p3] =
-0.8714 -0.0527 -0.3103
-0.3154 -0.0101 0.0874
-0.1972 -0.0029 0.1247
-0.1449 -0.0001 0.1294
-0.1151 0.0012 0.1271
-0.0959 0.0020 0.1231
-0.0824 0.0025 0.1187
-0.0723 0.0028 0.1144
-0.0646 0.0030 0.1104
-0.0584 0.0032 0.1068
-0.0533 0.0033 0.1034
-0.0491 0.0034 0.1003
-0.0455 0.0035 0.0975
-0.0425 0.0035 0.0949
-0.0398 0.0036 0.0925
-0.0375 0.0036 0.0903
-0.0355 0.0036 0.0882
-0.0336 0.0036 0.0863
-0.0320 0.0037 0.0845
-0.0305 0.0037 0.0828
-0.0292 0.0037 0.0812
-0.0280 0.0037 0.0797
-0.0268 0.0037 0.0783
-0.0258 0.0037 0.0769
-0.0249 0.0037 0.0757
-0.0240 0.0037 0.0745
-0.0232 0.0037 0.0733
-0.0224 0.0037 0.0722
-0.0217 0.0037 0.0712
-0.0211 0.0037 0.0702
. . .
. . .
. . .
如下:
ODE
我的曲线非常好。
我的问题是:我有fy = g1*p1+g2*p2+g3*p3; (1)
y= xj; % here has xj the same dim. than fy
f = @(yq)interp1(y, fy, yq);
tspan = 0:0.02:1;
x0 = 0.2;
[~, xt] = ode45(@(t,y)f(y), tspan, x0);
:
Library
这个Library = [L1 L2 L3]; % L1, L2, L3 are vectors of same size than p1, p2, p3
包含潜在的三元组,并且这些三元组中的一组(在行中给出......比如说568)可以让我得到我从(1)得到的同样漂亮的曲线。换句话说,如果我使用Library
,g1
和g2
更改g3
,l1
和l2
(可在行586中找到)来自l3
)我应该得到与(1)中几乎相同的结果。
我需要找到一种方法来找到这个三元组!
我可以处理的唯一信息是来自(1)的信息和我得到的曲线。如果我必须将所有曲线与我得到的曲线(1)进行比较,那将是非常糟糕的...因为我的Library
有1500个三元组,这意味着1500条曲线......在我得到三倍之后,我可以解决遵循系统的方式与我对(1)的方式相同。
Library
来自(1)的 fy = l1*p1+l2*p2+l3*p3; (2)
y= xj; % xj % has the same dim than fy
f = @(yq)interp1(y, fy, yq);
tspan = 0:0.02:1;
x0 = 0.2;
[~, xt2] = ode45(@(t,y)f(y), tspan, x0);
应该与(2)中的fy
近似。
更多信息:从线性回归中我应该得到一组在我的图书馆中/出口的三元组,但事实并非如此......因此,我的系统是草率的。出于这个原因,我必须找到一种方法以某种方式连接这两个输出。 (g和l)。
答案 0 :(得分:1)
您可以使用dsearchn
查找最近的三元组。
x = rand(1000,3);
xi = rand(1,3);
k = dsearchn(x,xi);
或者,您可以将所有1500条生成的曲线与原始曲线进行比较。有几种技术,例如这里描述的技术how to find the similarity between two curves and the score of similarity?