|
"Matthew " <mdornfe1@gmail.com> wrote in message <i7j698$ggr$1@fred.mathworks.com>...
> I'm using ode15s to solve a set of differential equations defined by this vector field:
>
> function [y]=field(t,a)
> n=0.5*sqrt(1+4.*length(a))-.5;
> x=a(1:n);
> W=reshape(a(n+1:length(a)),n,n);
> xdot=W*x;
> Wdot=0.01.*(eye(n)-x*x');
> y=[xdot;reshape(Wdot,n^2,1)];
>
> I want to store the eigenvalues of W as they change over time and plot them. Any ideas on how to do that? I tried using outputfcn, but that didn't really work out too well.
- - - - - - - - - - -
I don't think I see what the difficulty is here. I would assume that the y derived above is handed to ode15s via its odefun. On the output of ode15s are vectors T and solution array Y, either at ode15s' integration steps or at the steps requested in the input tspan. Each row of Y has n*(n+1) elements in which the last n^2 constitute the elements of W. What is to stop you from reshaping these into a square matrix, W, and evaluating its eigenvalues for each row of Y, and then plotting them as functions of the time in T?
Of course there is the question of what ordering to impose on the eigenvalues and how to plot if some of them become complex-valued.
Roger Stafford
|