help-octave
[Top][All Lists]
Advanced

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

Re: using interp1.m from Matlab in Octave?


From: David Bateman
Subject: Re: using interp1.m from Matlab in Octave?
Date: Tue, 08 May 2007 18:12:46 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Daniel Drucker wrote:
> I'm trying to get interp1.m from Matlab to work in Octave. Could  
> someone give me an idea why it fails?  (It works in Matlab.)

Firstly, why use interp1 from matlab. Octave has interp1.. Using interp1
from Mathworks certainly violates their license... Please don't use
mathwork copyright material in Octave, and if you do certainly don't say
so on a public mailing list (unless you like "cease and desist" letters
for angry Mathwork's lawyers).

> 
> octave:1> x=load timepoints.txt;
> octave:2> y=1:length(x);
> octave:3> i=min(x):range(x)/length(x)/2:max(x);
> octave:4> yi=interp1(x,y,i);
> octave(24383) malloc: *** vm_allocate(size=2147483648) failed (error  
> code=3)

You are allocating a 2GB block of memory. How is your kernel configured?
Does it allow 2GB blocks to be allocated? The matlab code for interp1
relies on additional code like ppval which you are probably using the
octave versions. These underlying functions don't give exactly the same
values but are self-consistent. Dump the matlab interp1.m function and
use the octave version. With

octave:5> load timepoints.txt
octave:6> x = timepoints;
octave:7> y=1:length(x);
octave:8> i=min(x):range(x)/length(x)/2:max(x);
octave:9> yi=interp1(x,y,i);
octave:10> plot (x,y,"r+")
octave:11> hold on
octave:12> plot (i,yi,"b*")

everything worked fine for me. There were quite a few changes when
interp1 was included in octave core in 2.9.6 for compatibility, and so
if you have Octave 2.9.6 or later it should work fine as above. There
might be some issues with the octave-forge versions for 2.1.73

D.

> octave(24383) malloc: *** error: can't allocate region
> octave(24383) malloc: *** set a breakpoint in szone_error to debug
> error: memory exhausted -- trying to return to prompt
> octave:4>
> 
> interp1.m is http://www.3e.org/private/interp1.m (from Matlab)
> timepoints is http://www.3e.org/private/timepoints.txt
> 
> 
> Daniel Drucker



reply via email to

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