From: Charles on
Hi,

I want to evaluate a function at points using the 'interp1' function by generating points between the minimum and maximum of the x-axis.

My code evaluates the points at
x = linspace (min(x), max(x), number_of_points)

The problem is that the code does not evaluate enough points at the extremes of x. For instance, if my original x is
x=[1, 1, 1, 1.1, 1.2, 2, 3, 4, 5, 6, 7, 8, 9, 9.2, 9.3, 9.4, 9.5, 9,5 9,5]
With my current code, I end up missing the actual shape of my function. Your help will be appreciated.

Charles
From: Walter Roberson on
Charles wrote:

> I want to evaluate a function at points using the 'interp1' function by
> generating points between the minimum and maximum of the x-axis.

> My code evaluates the points at
> x = linspace (min(x), max(x), number_of_points)

> The problem is that the code does not evaluate enough points at the
> extremes of x. For instance, if my original x is
> x=[1, 1, 1, 1.1, 1.2, 2, 3, 4, 5, 6, 7, 8, 9, 9.2, 9.3, 9.4,
> 9.5, 9,5 9,5] With my current code, I end up missing the actual shape
> of my function. Your help will be appreciated.

Is the total number of points to be generated to be held fixed? Or should the
algorithm generate as many additional points as necessary to find "reasonable"
smoothness at each location?

Are you interpolating the function values, or interpolating the x to evaluate
a function at? If you are interpolating function values, then unless your
function happens to be at most cubic, it is not clear to me that you will be
able to see "the actual shape" any more clearly: you would get to see the
_interpolated_ shape according to the interpolation method.
From: Jos (10584) on
"Charles " <nkwosman(a)yahoo.com> wrote in message <hu687e$ls1$1(a)fred.mathworks.com>...
> Hi,
>
> I want to evaluate a function at points using the 'interp1' function by generating points between the minimum and maximum of the x-axis.
>
> My code evaluates the points at
> x = linspace (min(x), max(x), number_of_points)
>
> The problem is that the code does not evaluate enough points at the extremes of x. For instance, if my original x is
> x=[1, 1, 1, 1.1, 1.2, 2, 3, 4, 5, 6, 7, 8, 9, 9.2, 9.3, 9.4, 9.5, 9,5 9,5]
> With my current code, I end up missing the actual shape of my function. Your help will be appreciated.
>
> Charles

if you have the signal processing toolbox: RESAMPLE; alternative this use of interp1 might suit you:

x = [1 1.1 2 6 10 11]
upsampleF = 4 ;
N = numel(x) ;
x2 = interp1(1:N, x, linspace(1, N, upsampleF * N) )

hth
Jos
From: Charles on

> Is the total number of points to be generated to be held fixed? Or should the
> algorithm generate as many additional points as necessary to find "reasonable"
> smoothness at each location?
>
> Are you interpolating the function values, or interpolating the x to evaluate
> a function at? If you are interpolating function values, then unless your
> function happens to be at most cubic, it is not clear to me that you will be
> able to see "the actual shape" any more clearly: you would get to see the
> _interpolated_ shape according to the interpolation method.

The y-axis for all my data runs from 0 to 1, the x-axis range is not fixed and varies in all the data. The number of points to be generated by the algorithm is fixed. Basically, the dimension of the data is in the hundreds, I just want to resample to reduce the size to say 20 points. And the dimension varies in all of the data.
From: Charles on

> if you have the signal processing toolbox: RESAMPLE; alternative this use of interp1 might suit you:
>
> x = [1 1.1 2 6 10 11]
> upsampleF = 4 ;
> N = numel(x) ;
> x2 = interp1(1:N, x, linspace(1, N, upsampleF * N) )
>
> hth
> Jos

The thing is that I do not quite know the exact shape of the curves, i.e where the minimum and maximum values lie. I will want a function that resamples say 1/3rd at the min, 1/3rd at the middle, and 1/3rd at the maximum areas of the function. The curve is shaped like a sigmoid.