I am struggling in finding a way to write a code which can let me do the following:
I have a nonlinear ODE called fy
.
fy = g1*p1+g2*p2+g3*p3; % g1,g2,g3 are real-valued numbers and p1,p2,p3 are vectors
g1
, g2
and g3
are constants found by the method of linear regression.
g1 = 591.5121
g2 = 35.1352
g3 = 107.5798
the vectors p1
, p2
and p3
are given as follow: (sorry than I am not giving the hole vector p1
, p2
and p3
since they have 1500 rows:
[ 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
. . .
. . .
. . .
I am solving the ODE
as follows:
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);
And I get a very nice curve.
My problem is: I have a Library
:
Library = [L1 L2 L3]; % L1, L2, L3 are vectors of same size than p1, p2, p3
This Library
contains potential triples, and ONE SET of these triples (given in row...lets say 568) can allow me to get the same nice curve I am getting from (1). In other words, if I change g1
, g2
and g3
with l1
, l2
and l3
(which are found in the row 586 from Library
) I should have almost the same results as in (1).
I need to find a way to find this SET of triples!
The only information to my disposal is the information from (1) and the curve I get. It would be awful if I have to compare all the curves to the one I get from (1)... because my Library
has 1500 triples which implies 1500 curves... After I have my triples I could solve the following system in the same way as I did it with (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);
fy
from (1) should be approximate to fy
from (2).
some more info: From linear regression I was supposed to get a set of triples that are/exits in my library, but this is not the case... my system is, because of this, sloppy. For this reason I have to find a way to connect in some way these two outputs. (the g's and the l's).