MATLAB Answers

solve ODE using mass matrix and optimize( or sfit) for constant k

1 view (last 30 days)
Abhishek Shahi
Abhishek Shahi on 6 May 2021
I have following ODE (can be up to 50 equations) and I know the inditial conditions. I would like to solve the ODEs using mass matrix approach and fit (or optimize) it for the constant k , simultaneously.
% folowing 6 ODE
dy1= -k(1)*y(1)
dy2= -k(1)*y(2) + k(2)*y(3)
dy3= -k(2)*y(3)+ k(3)*y(4)
dy4= -k(3)*y(4) + k(4)*y(5)
dy5= -k(4)*y(5) + k(5)*y(6)
dy6= -k(5)*y(6)
yo=[1:6]; % e.g. inital condition
t=[1:11]; % time span
% y is the solution should be used for fitting (or optimisation )
y=[0.0507028494426047 0.0391772076592548 0.0239936934256099 0.0136320134992300 0.00834432867659483 0.00496713242934561 0.00289990776880902 0.00227072723841650 0.00134219884538243 0.00144485869761514 0.000954842993410321
0.0449696949945177 0.0306503331602409 0.0166143496301845 0.00843215675170465 0.00470145257948545 0.00256569627280364 0.00137010277822527 0.00103256893122316 0.000561318403514916 0.000615978094736525 0.000379910700400407
0.0391124886980205 0.0233551513099763 0.0111309727505778 0.00501552652693363 0.00253435840314969 0.00126196768029146 0.000613422886429227 0.000444025306296506 0.000220983300037256 0.000247466678883997 0.000141909740882417
0.0333986566211517 0.0173566786561615 0.00722629225046896 0.00287365853628619 0.00130948595294191 0.000592232245482717 0.000260807030009474 0.000180954826980453 8.20843481602059e-05 9.38988749971876e-05 4.98825894663671e-05
0.0280293764773304 0.0125957834222410 0.00455251874259976 0.00158851929625593 0.000649668649977560 0.000265678988505308 0.000105514529162416 7.00347502676200e-05 2.88320883066407e-05 3.37246378721650e-05 1.65382627591214e-05
0.0231408090337721 0.00893630956704687 0.00278695045402996 0.000848510074328506 0.000310010718055328 0.000114140973574678 4.07005962733033e-05 2.57945112215959e-05 9.59745622162058e-06 1.14898166389124e-05 5.18346441972883e-06];
y0=y(:,1) ; % e.g. inital condition

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!