In this example code, I can't get interpl or spline to produce output, whats wrong?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

In this example code, I can't get interpl or spline to produce output, whats wrong?

mlytle0
Hi all,

Here is the code I am testing with:

x=[0,.11,.15,.18,.25,.32,.35,.39,.42,.44,.48,.50];

y = [0 , 1 , 3 , 5 , 12 , 10 , 9 , 7 , 5 , 3 , 7 , 10];

figure(1)

plot(x,y);

x1=linspace(0,5,-.05);

y1 = spline(x,y,x1)

figure(2)

plot(x1,y1);

axis([0, .5, 0, 15])


y2 = interp1(x,y,x1)

figure(3)

plot(x1,y2);

axis([0, .5, 0, 15])


I do get plots for figures 2 and 3, but they are empty.


Scratching my head...How do you interpolate randomly spaced data?


Any help is appreciated...


Thanks,

Mark Lytle

Houston




_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: In this example code, I can't get interpl or spline to produce output, whats wrong?

bpabbott
Administrator

On Apr 3, 2012, at 5:41 PM, Mark Lytle wrote:

> Hi all,
>
> Here is the code I am testing with:
>
> x=[0,.11,.15,.18,.25,.32,.35,.39,.42,.44,.48,.50];
> y = [0 , 1 , 3 , 5 , 12 , 10 , 9 , 7 , 5 , 3 , 7 , 10];
> figure(1)
> plot(x,y);
>  
> x1=linspace(0,5,-.05);
>
> y1 = spline(x,y,x1)
> figure(2)
> plot(x1,y1);
> axis([0, .5, 0, 15])
>
> y2 = interp1(x,y,x1)
> figure(3)
> plot(x1,y2);
> axis([0, .5, 0, 15])
>
> I do get plots for figures 2 and 3, but they are empty.
>
> Scratching my head...How do you interpolate randomly spaced data?
>
> Any help is appreciated...
>
> Thanks,
> Mark Lytle
> Houston

x1=linspace(0,5,-.05)
x1 =  5

Your syntax for linspace is wrong. Take a look at "help linspace"

Ben


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave