Changing parameters in an ODE model
1 次查看(过去 30 天)
显示 更早的评论
I have created an estimation ode model, and now I would like to test different parameter values to see which is a best fit. So far I have this:
z=0;
f = [1 2 3]
ft =[1 2 3];
g = [4 5 6];
gt = [1 2 3];
Time = [0 30];
IC = 2.5;
for a = [1:3]
for b = [1:3]
Q = [a b];
[t,y] = ode45(@(t,y) Test(t,y,Q,ft,f,gt,g), Time, IC);
end
y=y'
z=z+1;
out(z,:) = [a b y]
end
Which works for single values, i.e a = 1 and b=1, but the moment i try to change the values it gives me the error; Subscripted assignment dimension mismatch.
My ODE file is
function dydt = Test(t,y,Q,ft,f,gt,g)
f = interp1(ft, f, t,'linear', 'extrap');
g = interp1(gt, g, t, 'linear', 'extrap');
dydt = Q(1)*f+Q(2)*g*y;
end
It all works before I tried to change it to test a range of parameters. Essentially I just want it to test each value individually and store the results away, which is what I tried to do with the 'out' function, but I cannot seem to get it to work. Any help would be greatly appreciated.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!