Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fixed Step ODE Solvers in MATLAB

256 views
Skip to first unread message

Will

unread,
Feb 11, 2010, 8:41:05 AM2/11/10
to
I am trying to create a model of differential equations in MATLAB that I previously modelled in Simulink. In Simulink I used a fixed step solver because I have data at specific intervals.

Are there any fixed step solvers in MATLAB? If so I cannot find them (used docsearch ode1,2,3,4,5 - no results other than those in Simulink). I think they exist as I have found this technical note on the Mathworks website listing the available solvers (ODE1,2,3,4,5)<<http://www.mathworks.com/support/tech-notes/1500/1510.html#time>>. But I cannot find them, have they been removed?

I have tried replacing ode45 with ode5 and I get the following error:
??? Undefined function or method 'ode5' for input arguments of type 'function_handle'. It is as if they don't exist.

I am using MATLAB 2008a.

Any advice would be appreciated, Thanks.

Arnaud Miege

unread,
Feb 11, 2010, 9:20:32 AM2/11/10
to

"Will " <w.br...@bradford.ac.uk> wrote in message
news:hl11dh$ji6$1...@fred.mathworks.com...

MATLAB only provides variable-step solvers. However, in the technical note
you mention, you'll notice that there are hyperlinks for each of the ode1,
ode2, etc... that you can copy and paste and add to add to your MATLAB path.
However, note the following warning:

"The MATLAB ODE solvers utilize these methods by taking a step, estimating
the error at this step, checking to see if the value is greater than or less
than the tolerance, and altering the step size accordingly. These
integration methods do not lend themselves to a fixed step size. Using an
algorithm that uses a fixed step size is dangerous since you can miss points
where your signal frequency is greater than the solver frequency. "


Simulink requires fixed-step solver for code generation and implementation
on real-time platforms (where you can't go back in time). What I don't
understand is why would you want to re-implement something in MATLAB that
you have already done in Simulink? It doesn't really make sense to me. Also,
even if you have data at specific intervals, it doesn't mean you have to use
a fixed-step solver, you can still use a variable-step solver.

HTH,

Arnaud


Steven Lord

unread,
Feb 11, 2010, 9:23:13 AM2/11/10
to

"Will " <w.br...@bradford.ac.uk> wrote in message
news:hl11dh$ji6$1...@fred.mathworks.com...
>I am trying to create a model of differential equations in MATLAB that I
>previously modelled in Simulink. In Simulink I used a fixed step solver
>because I have data at specific intervals.
>
> Are there any fixed step solvers in MATLAB? If so I cannot find them (used
> docsearch ode1,2,3,4,5 - no results other than those in Simulink). I think
> they exist as I have found this technical note on the Mathworks website
> listing the available solvers
> (ODE1,2,3,4,5)<<http://www.mathworks.com/support/tech-notes/1500/1510.html#time>>.
> But I cannot find them, have they been removed?

AFAIK they have never been included in MATLAB itself, but you can download
them from section 6 of the document you linked above.

--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


Will

unread,
Feb 11, 2010, 9:49:04 AM2/11/10
to
"Arnaud Miege" <arnaud...@nospam.mathworks.co.uk> wrote in message <hl13ng$l6p$1...@fred.mathworks.com>...

Thanks for your response Arnaud, thank-you for pointing out the links. If it is such bad practice to use fixed step solvers why are they made available in Simulink?

I have been working on my current R&D project in Simulink for 1 year now. I have grown tired of the graphical nature of Simulink and having to interface with MATLAB for inputs and outputs etc.. The models now look untidy and difficult to understand (and importantly, difficult to debug!). I have written a function out in MATLAB for an ode solver and it is easier to interface with MATLAB functions, easier to comment, easier to understand and modify.

I think Simulink is useful as an introductory tool to mathematical modelling but with more complex modelling requirements the graphical nature of Simulink becomes an unwanted overhead. No doubt people will have differing views but for my particular application this is the case.

Arnaud Miege

unread,
Feb 11, 2010, 11:19:17 AM2/11/10
to

"Will " <w.br...@bradford.ac.uk> wrote in message
news:hl15d0$cid$1...@fred.mathworks.com...

>
> Thanks for your response Arnaud, thank-you for pointing out the links. If
> it is such bad practice to use fixed step solvers why are they made
> available in Simulink?
>
> I have been working on my current R&D project in Simulink for 1 year now.
> I have grown tired of the graphical nature of Simulink and having to
> interface with MATLAB for inputs and outputs etc.. The models now look
> untidy and difficult to understand (and importantly, difficult to debug!).
> I have written a function out in MATLAB for an ode solver and it is easier
> to interface with MATLAB functions, easier to comment, easier to
> understand and modify.
>
> I think Simulink is useful as an introductory tool to mathematical
> modelling but with more complex modelling requirements the graphical
> nature of Simulink becomes an unwanted overhead. No doubt people will have
> differing views but for my particular application this is the case.

Thanks, that's an interesting perspective. In my experience, people are
moving from MATLAB to Simulink, because it is easier to understand a
graphical model than hundreds (or thousands) of lines of codes, and also
easier to debug. It is also possible to control Simulink from MATLAB for
automation or batch processing. As I mentioned, fixed-step solvers are
required in Simulink for generating C code and real-time implementation.

Anyway, that's my personal opinion...

Arnaud

Steven Lord

unread,
Feb 11, 2010, 1:39:24 PM2/11/10
to

"Will " <w.br...@bradford.ac.uk> wrote in message
news:hl15d0$cid$1...@fred.mathworks.com...

> "Arnaud Miege" <arnaud...@nospam.mathworks.co.uk> wrote in message
> <hl13ng$l6p$1...@fred.mathworks.com>...

*snip*

> Thanks for your response Arnaud, thank-you for pointing out the links. If
> it is such bad practice to use fixed step solvers why are they made
> available in Simulink?
>
> I have been working on my current R&D project in Simulink for 1 year now.
> I have grown tired of the graphical nature of Simulink and having to
> interface with MATLAB for inputs and outputs etc.. The models now look
> untidy and difficult to understand (and importantly, difficult to debug!).
> I have written a function out in MATLAB for an ode solver and it is easier
> to interface with MATLAB functions, easier to comment, easier to
> understand and modify.

Just out of curiosity, do your models have everything in one block diagram
or do you use subsystems with some collection of related blocks?

http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/ug/f4-53172.html

If you're not using subsystems, they may help improve the tidiness of the
models and also help you in localizing any problems during debugging ("Let's
check the output of this subsystem, okay it's fine. On to the next
subsystem...")

Will

unread,
Feb 12, 2010, 4:05:24 AM2/12/10
to
"Steven Lord" <sl...@mathworks.com> wrote in message <hl1isq$3n8$1...@fred.mathworks.com>...

Yes, I use a number of subsystems and multiplexing of signals in order to keep the model as readable as possible. This means the top few levels of the model are simplistic but once you dig down beyond this you still find the same level of complexity.

My model is that of an induction motor that accepts real world inputs to be used for fault detection. This is why I want the model to be fixed step - for direct comparison with the real world input-output relationship. I don't see the point of having a high fidelity modelled signal and a low-fidelity real world signal.

Sim Power Systems may have been helpful but it is not a standard block set.

Using the MATLAB debugger and recently the Profiler have really helped me to get to grips with my application. I can keep the separate parts of the model in distinct functions (not just reams and reams of code). The calculations are written out line by line - very difficult to misunderstand in this format.

By the way, do you know whether it is easier to develop C code using MATLAB or Simulink? Eventually I need to run the algorithms on a microprocessor.

0 new messages