octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ode output orientation


From: c.
Subject: Re: ode output orientation
Date: Fri, 21 Oct 2016 18:33:45 +0200

On 21 Oct 2016, at 18:20, Rik <address@hidden> wrote:
> 
> 
> What version of Matlab was this?  The documentation
> http://www.mathworks.com/help/matlab/ref/ode23.html clearly states that the
> time variable is a column vector (Nx1).  It also says that each row of the
> output solution corresponds to an entry in t (Nx#_of_ode_vars).

This happens only when the output is one struct rather than a set of arrays,
the same page that you linked in the section "Output Arguments" in the 
subsection
labelled "sol — Structure for evaluation" (you need to click to open it)
states that sol.x is a row vector and that each column of sol.y corresponds to 
the solution at a given time instant.


> If Matlab has changed things around not only the outputs needs to be
> transposed, but also Octave's documentation needs to be updated.  And what
> about ode45?

I think Sebastian's patch was intended as just an example he was proposing the 
same change for ode45 as well.

> -- Code --
> fvdb = @(vt,vy) [vy(2); (1 - vy(1)^2) * vy(2) - vy(1)];
> sol=ode45(fvdb,[0 40],[2 0]);
> size(sol.x)
> ans =
> 
>   100     1
> -- End Code --
> 
> It seems like this would need a fix at a lower level than either ode23.m or
> ode45.m.  The very end of integrate_adaptive.m is
> 
> -- Code --
>  ## Set up return structure
>  solution.t = t(:);
>  solution.x = x.';
> 
> endfunction
> -- End Code --
> 
> Why not undo the transposing here?

because AFAICS for some strange reason the convention used in Matlab differs 
whether 
the solver is invoked as 

[x, y] = odeXX (...)

or

sol = odeXX (...)

I guess this has to do with the way interpolation is performed in deval ....

> If this is confirmed with a modern version of Matlab then I agree we should
> commit a patch before the 4.2.0 release.

I think the solution Sebastian proposes is correct, what do you think?

> --Rik

c.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]