Initial Conditions parameter for ode23
3 次查看(过去 30 天)
显示 更早的评论
In the documentation for ode23, it says the initial conditions must be stated as a vector. How would it be possible to make the initial conditions a matrix? I am doing this in order to avoid having a large sparse matrix and having to use a Kronecker product.
0 个评论
回答(2 个)
Mischa Kim
2014-1-14
The exact same way, just write down the matrix, e.g., A0 = [1 2 3; 4 5 6].
0 个评论
David Sanchez
2014-1-14
There is a very clear example in the documentation:
To simulate a system, create a function vdp1000 containing its equations
function dy = vdp1000(t,y)
dy = zeros(2,1); % a column vector
dy(1) = y(2);
dy(2) = 1000*(1 - y(1)^2)*y(2) - y(1);
For this problem, we will use the default relative and absolute tolerances (1e-3 and 1e-6, respectively) and solve on a time interval of [0 3000] with initial condition vector [2 0] at time 0.
[T,Y] = ode15s(@vdp1000,[0 3000],[2 0]); % ode15s and ode23 are used in the same way
The initial condition vector represents y(1) and y(2) initial values ( y(1)_0 = 2 ; y(2)_0 = 0 ), and that is why they have to be included in the same array.
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!