ODE15s time vector size
古いコメントを表示
Hi everyone,
I am using an ode15s solver to solve some coupled equations and I put this into a for loop and for each iteration I solve the same equations but changing one parameter that goes into the equation (it's a constant). Now what I am seeing is that each time ode is giving me results, the time vector has a different size and I can't then put all of that into one matrix, since the resulting vectors are all different size. Is there a way around it? I am ok if the matrix would be of certain size to fit the longest time vector and the shorter vectors would have zeros added i.e.
So what I am doing:
for i=1:length(pump_barrel)
t_span = [0 3e-6]; % time-span
i_values = [0.9 0 0.1 0 0]; % initial values. [0 0 0] should be ok
tol = 0.0000000000001;
options = odeset('RelTol',tol,'AbsTol',[tol tol tol tol tol]);
[t,y] = ode15s(@(t,y) NV(t,y,argins),t_span,i_values,options); % calling the ode-solver
PL=y(:,2)+y(:,4);
disp(length(t))
PL_time(:,i)=y(:,2)+y(:,4); % here is a problem, first vector goes into the PL_time matrix, but the second is larger and throws error
end % end of the for loop in which I am changing a parameter in argins
採用された回答
その他の回答 (2 件)
Torsten
2018 年 3 月 15 日
0 投票
If t_span has more than two elements, the ode integrator will output the solution at exactly the specified time instants.
Best wishes
Torsten.
2 件のコメント
Lukasz Dziechciarczyk
2018 年 3 月 15 日
Star Strider
2018 年 3 月 15 日
With more than two values, the ODE solvers will output its results at times closely corresponding to the times in the vector. For three values, it would output a three-row time vector (in your code, ‘t’), and a three-row vector or matrix of the ‘y’ values.
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!