Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
eigenvalues in ode problem

Subject: eigenvalues in ode problem

From: Matthew

Date: 24 Sep, 2010 21:47:20

Message: 1 of 2

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.

Subject: eigenvalues in ode problem

From: Roger Stafford

Date: 24 Sep, 2010 23:21:08

Message: 2 of 2

"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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us