[R] R and MatLab implementations of the same model differs

Jannetta Steyn jannetta at henning.org
Thu Jul 4 18:42:18 CEST 2013


 Hi Ben and others

I don't quite know how to explain the "doesn't work" in more detail without
any visual aid. When you run the two scripts it is easy to see the
difference. MatLab produces a line on x= -55. This is what I expect - a
more or less straight line. R on the other hand the result drops from -55
(the initial value) to -80 and then goes up to -71.37092.

The two scripts have exactly the same equations. I have even named the
variables the same in the two scripts and copied the equations across to
make sure I haven't made any typos.

Can one attach images to posts? I'll try. The flatline image is the plot
from MatLab and the other is the plot from R.

Thanks
Jannetta


On 4 July 2013 16:52, Ben Bolker <bbolker at gmail.com> wrote:

> Berend Hasselman <bhh <at> xs4all.nl> writes:
>
> >
> >
> > On 04-07-2013, at 17:15, Jannetta Steyn <jannetta <at> henning.org>
> wrote:
> >
> > > Hi folks
> > >
> > > I have implemented a model of a neuron using Hodgkin Huxley equations
> in
> > > both R and MatLab. My preference is to work with R but R is not giving
> me
> > > the correct results. I also can't use ode45 as it just seems to go
> into an
> > > indefinite loop. However, the MatLab implementation work fine with
> > >  the same
> > > equations, parameters and initial values and ode45. Below is my R and
> > > MatLab implementations.
> > >
> >
> > No problem in running your R file. Have plot.
> > (Mac mini Core2Duo 2.66Ghz running R 3.0.1 Patched
> > (2013-06-19 r62992) on Mac OS X 10.8.4:  16.5 seconds.)
> >
> > Trying to run your Matlab file in Octave.
> >  No success yet because of unavailable ode45.
>
>    I'm impressed that you (BH) went to the trouble of checking
> on this vague "doesn't work" question.  If you want to go farther
> I think you can get ode45 for octave by installing the odepkg
> package:
>
> http://octave.sourceforge.net/odepkg/index.html
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 

===================================
Web site: http://www.jannetta.com
Email: jannetta at henning.org
===================================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Rplot01.png
Type: image/png
Size: 3877 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130704/bd9b8f59/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MatPlot01.png
Type: image/png
Size: 30618 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130704/bd9b8f59/attachment-0001.png>


More information about the R-help mailing list