If I understand correctly, what you're missing is the ability to have a array 
of values that is regularly-spaced but does not start at x=1. You have several 
options:
- Just subtract 2 from all your Xq values. 
- Create a type
    immutable ShiftedInterpGrid{T,N,BC,IT}
        IG::InterpGrid{T,N,BC,IT}
        offset::Vector{T}
    end
  and define getindex() for this type to do the subtraction for you and pass 
the "real" work onto IG. You could also scale the values if they aren't 
usually spaced by 1.
- Use the (undocumented and incomplete) InterpIrregular (see interp.jl),
      ig = InterpIrregular([X,], V, BCnil, InterpLinear)

The latter will be slower than either of the other two, simply because there 
is more computation required for irregular grids than for regular ones.

--Tim
    
On Monday, April 14, 2014 10:11:44 PM Spencer Lyon wrote:
> I need to do some basic interpolation and think Grid.jl should provide all
> the functionality I need, but I can’t quite get it to work for me.
> 
> I am essentially looking to do something like what is described for this
> form of the interp1 matlab function (copied and pasted excerpt from
> documentation):
> 
> Vq = interp1(X,V,Xq) interpolates to find Vq, the values of the underlying
> function V=F(X) at the query points Xq. X must be a vector of length N.
> 
> A minimal example from the Matlab docs (slightly adapted) of what I would
> like to do is
> 
> X = 3:15;
> V = sin(X);
> Xq = 4:.25:12;
> Vq = interp1(X,V,Xq);
> 
> Here is what I have so far in Julia:
> 
> X = [3:15]
> V = sin(X);
> Xq = [4:.25:12]
> 
> ig = InterpGrid(V, BCnil, InterpLinear)
> 
> As far as I understand, I can now “index” the ig object to do
> interpolation. The problem I am having is that the portion of the grid I
> would like to interpolate over, Xq, is not represented in terms of indexes,
> but rather points on the interval [minimum(X), maximum(X)].
> 
> What do I need to do to evaluate the function underlying ig at the grid
> points Xq?

Reply via email to