Solving the same linear ODE with several initial conditions

1 view (last 30 days)
Hi, I want to solve a system of the form X(t)'=A*X(t) several times with different initial conditions. Of course, I could solve it separately for each initial condition in a loop, but I was hoping that there is a vectorized method for this.
Here's a more precise description of what I'm looking for: A is an NxN matrix. X0 is MxN where M is the number of initial conditions. TIME is a 1xT vector where T is the number of time bins I want for my solution. I would like a solution X that is MxNxT (or NxMxT, etc) that represents the solution to X'=A*X for each initial condition and at each time.
I first tried using expm since I could apply the result to the matrix X0, but I would need to calculate expm separately at each time bin (requiring a time loop).
I then thought of using ode45 since it takes a vector of times. But it takes only one initial condition (requiring a loop over X0).
Any ideas?

Answers (0)

Community Treasure Hunt

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

Start Hunting!