0

私は次の関数を離散形式で持っています(つまり、それらは配列です):

p1_1 of dim(200x1)
p1_2 of dim(200x1)
p1_3 of dim(200x1)
p2_1 of dim(200x1)
p2_2 of dim(200x1)
p2_3 of dim(200x1) 

関数p1_1, p1_2, p1_3は のポイント で評価されてx1 = 0:(10/199):10おり、 関数p2_1, p2_2, p2_3はポイント で評価されていx2 = 0:(10/199):10ます。

関数の値と関数が評価されたポイントがあるので、次のことができます。

fun1_of_p1 = @(xq1) interp1(x1,p1_1,xq1);
fun1_of_p2 = @(xq1) interp1(x1,p1_2,xq1);
fun1_of_p3 = @(xq1) interp1(x1,p1_3,xq1);

fun2_of_p1 = @(xq2) interp1(x2,p2_1,xq2);
fun2_of_p2 = @(xq2) interp1(x2,p2_2,xq2);
fun2_of_p3 = @(xq2) interp1(x2,p2_3,xq2);

そして、次のことができる必要があります。

new_fun1 = @(xq1,xq2) fun1_of_p1.*fun2_of_p1;
new_fun2 = @(xq1,xq2) fun1_of_p1.*fun2_of_p2;
new_fun3 = @(xq1,xq2) fun1_of_p1.*fun2_of_p3;
new_fun4 = @(xq1,xq2) fun1_of_p2.*fun2_of_p1;
new_fun5 = @(xq1,xq2) fun1_of_p2.*fun2_of_p2;
new_fun6 = @(xq1,xq2) fun1_of_p2.*fun2_of_p3;
new_fun7 = @(xq1,xq2) fun1_of_p3.*fun2_of_p1;
new_fun8 = @(xq1,xq2) fun1_of_p3.*fun2_of_p2;
new_fun9 = @(xq1,xq2) fun1_of_p3.*fun2_of_p3;

ついに

 last_fun = @(xq1,xq2) gamma1*new_fun1 + gamma2*new_fun2 +...
 gamma3*new_fun3 + gamma4*new_fun4 + gamma5*new_fun4 +...
 gamma6*new_fun6 + gamma7*new_fun7 + gamma8*new_fun8 +...
 gamma9*new_fun9;

-valuesgammaは単なる定数 (実数値定数) です。を定義した後last_fun、それに適用ode45する必要がありますが、その方法がわかりません。試してみました:

([T,V] = ode45(@(xq1,xq2)last_fun(xq1,xq2),tspan,x0)

しかし、うまくいきません。実際、私が行ったすべてが正しいかどうかはわかりませんので、フィードバックをいただければ幸いです。

4

1 に答える 1

2

関数のハンドルは、特にその関数を識別するタグ(またはアドレス、ID など) と考えてください。これらのタグは数字で問題ありません (コンピューター内のすべてのものは数字です) が、関数が受け取る可能性のある値を表していません。値を取得するには、関数の IDと関数の引数を指定する必要があります。

ここで、関数の乗算と言うときは、関数のタグではなく、関数のの乗算を返す関数を意味します。これは正しい定義につながります:

new_fun1 = @(xq1,xq2) fun1_of_p1(xq1).*fun2_of_p1(xq2);
new_fun2 = @(xq1,xq2) fun1_of_p1(xq1).*fun2_of_p2(xq2);
new_fun3 = @(xq1,xq2) fun1_of_p1(xq1).*fun2_of_p3(xq2);
new_fun4 = @(xq1,xq2) fun1_of_p2(xq1).*fun2_of_p1(xq2);
new_fun5 = @(xq1,xq2) fun1_of_p2(xq1).*fun2_of_p2(xq2);
new_fun6 = @(xq1,xq2) fun1_of_p2(xq1).*fun2_of_p3(xq2);
new_fun7 = @(xq1,xq2) fun1_of_p3(xq1).*fun2_of_p1(xq2);
new_fun8 = @(xq1,xq2) fun1_of_p3(xq1).*fun2_of_p2(xq2);
new_fun9 = @(xq1,xq2) fun1_of_p3(xq1).*fun2_of_p3(xq2);

last_fun式も同様に修正してください。

last_fun = @(xq1,xq2) ...
     gamma1*new_fun1(xq1,xq2) ...
   + gamma2*new_fun2(xq1,xq2) ...
   + gamma3*new_fun3(xq1,xq2) ...
   + gamma4*new_fun4(xq1,xq2) ...
   + gamma5*new_fun4(xq1,xq2) ...
   + gamma6*new_fun6(xq1,xq2) ...
   + gamma7*new_fun7(xq1,xq2) ...
   + gamma8*new_fun8(xq1,xq2) ...
   + gamma9*new_fun9(xq1,xq2);

への正しい呼び出しは次のようにode45なります。

[T,V] = ode45(last_fun,tspan,x0);

ただし、tspanx0はベクトルであり、tspan昇順で並べ替えられます。

于 2014-10-16T11:50:25.957 に答える