Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
interpolate

Subject: interpolate

From: Dave Brackett

Date: 1 Aug, 2008 10:59:03

Message: 1 of 7

I have 12 data points at the following coordinates:

x: y:
78 6.00E+07
233 6.00E+07
349 6.00E+07
466 6.00E+07
587 6.00E+07
699 6.00E+07
807 4.00E+07
932 3.00E+07
1047 2.00E+07
1175 1.00E+07
1281 1.00E+07
1397 5.00E+06

At the midpoint between each point y is 0 (not listed
above). I want to interpolate using an exponential function
between the y values thereby creating peaks. A picture of
the kind of thing I want the results to be can be found
here:
http://upload2.net/page/download/m8KAixt8aZdvCTp/example+of+peaks.pdf.html

Thanks.

Subject: interpolate

From: John D'Errico

Date: 1 Aug, 2008 13:26:01

Message: 2 of 7

"Dave Brackett" <davebrackett@hotmail.com> wrote in message
<g6uq9n$b2p$1@fred.mathworks.com>...
> I have 12 data points at the following coordinates:
>
> x: y:
> 78 6.00E+07
> 233 6.00E+07
> 349 6.00E+07
> 466 6.00E+07
> 587 6.00E+07
> 699 6.00E+07
> 807 4.00E+07
> 932 3.00E+07
> 1047 2.00E+07
> 1175 1.00E+07
> 1281 1.00E+07
> 1397 5.00E+06
>
> At the midpoint between each point y is 0 (not listed
> above). I want to interpolate using an exponential function
> between the y values thereby creating peaks. A picture of
> the kind of thing I want the results to be can be found
> here:
>
http://upload2.net/page/download/m8KAixt8aZdvCTp/example+of+peaks.p
df.html
>
> Thanks.

You might find a better way to provide your
example than that service. I refuse to answer
the questions it wants me to respond to, just
to look at your picture.

And please explain yourself more clearly,
although if you did explain more clearly, you
probably would solve your own question. What
exponential function will you use? Do you want
the interpolant to go through zero between
every pair of data points?

Why in gods name do you want to interpolate
in this way anyway?

John

Subject: interpolate

From: Dave Brackett

Date: 1 Aug, 2008 16:14:02

Message: 3 of 7

> You might find a better way to provide your
> example than that service. I refuse to answer
> the questions it wants me to respond to, just
> to look at your picture.

sorry about that - it didn't bug me with questions when I
tested it. try this:
http://www.filedropper.com/exampleofpeaks

> And please explain yourself more clearly,
> although if you did explain more clearly, you
> probably would solve your own question. What
> exponential function will you use? Do you want
> the interpolant to go through zero between
> every pair of data points?

Hopefully when you see the picture it will make more sense.
I'm not sure which exponential function to use but I
imagine it will be a simple job to replace functions once
the method is worked out, so choose a common one to start
with.

I am only specifying the peak coordinates and that the y
coord is 0 between each peak. I want to generate the data
points between each peak and 0 to get something similar to
the plot in the picture.
 
> Why in gods name do you want to interpolate
> in this way anyway?

To generate the plot shown in the picture. hope that makes
a bit more sense. i look forward to hearing from you again.
thanks.

Subject: interpolate

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 1 Aug, 2008 19:05:49

Message: 4 of 7

In article <g6uq9n$b2p$1@fred.mathworks.com>,
Dave Brackett <davebrackett@hotmail.com> wrote:
>I have 12 data points at the following coordinates:
>
>x: y:
>78 6.00E+07
>233 6.00E+07
>349 6.00E+07
>466 6.00E+07
>587 6.00E+07
>699 6.00E+07
>807 4.00E+07
>932 3.00E+07
>1047 2.00E+07
>1175 1.00E+07
>1281 1.00E+07
>1397 5.00E+06

>At the midpoint between each point y is 0 (not listed
>above). I want to interpolate using an exponential function
>between the y values thereby creating peaks.

Start from an x location that has a y of 0 (e.g., half way
between adjacent x.) Call it H (for "here"). Take the distance
between where you are (H) and the next peak (call it T, for "there").
In that distance, you have to rise from 0 to the value of that next peak.
You wish to use an exponential function, so you will be using exp(c*(t-H))
where t is the position being interpolated, and for some constant c
that depends upon the height you are rising to. However,
that function can never go negative, and at t == H would have a value of 1.
The easiest solution is to use (exp(c*(t-H)) - 1) .

Now you have to figure out the constant c. Keeping in mind the -1
in the equation, you need to rise from 1 to a height of y+1 over a
distance of T-H . So y+1 = exp(c*(T-H)). Take the log of both sides.
log(y+1) = c*(T-H) . Divide through by T-H to get
c = log(y+1) / (T-H) . Now you know that from t=H to t=T, the
equation is (exp(log(y+1) / (T-H) * (t-H)) - 1).

You can use very similar logic to figure out how to fall from
a given height to 0 over a particular distance.

Now your only issues are how to handle the endpoints. You haven't
included any information that would allow us to figure out
the initial point at the left at which the y value should be 0,
nor the terminal point at the right at which the y value should be 0.

If it happened that for the purposes of the problem the peaks
had to be symmetric, then we could calculate the starting and ending
points (but determining the 0 point between peaks would be more
complex.) You gave no indication that the peaks should be
symmetrical -- instead you indicated that you wanted to use
interpolation, which is a term that implies "approximation" and
has no inherent implication of symmetry. For example you might have
been thinking of using a spline fit (somehow or other!) to
determine the data values. When you have an equation family
that gives an exact shape (e.g., "exponential") then the term
that is used for the intermediate values is "calculate", not
"interpolate". On the basis of the information we were given,
a non-symmetric peak model is at least as valid an interpolation as
any other.

The calculation I show above to determine the center positions
and the constants for the exponentials can be vectorized without
much difficulty.
--
  "And believe me, I was very lousy yesterday.
   I had nothing to say, and, by God, I said it."
                                          -- Walter Wellesley Smith

Subject: interpolate

From: John D'Errico

Date: 1 Aug, 2008 23:20:03

Message: 5 of 7

"Dave Brackett" <davebrackett@hotmail.com> wrote in message
<g6vcoa$peq$1@fred.mathworks.com>...
> > You might find a better way to provide your
> > example than that service. I refuse to answer
> > the questions it wants me to respond to, just
> > to look at your picture.
>
> sorry about that - it didn't bug me with questions when I
> tested it. try this:
> http://www.filedropper.com/exampleofpeaks

That one works.

 
> > And please explain yourself more clearly,
> > although if you did explain more clearly, you
> > probably would solve your own question. What
> > exponential function will you use? Do you want
> > the interpolant to go through zero between
> > every pair of data points?
>
> Hopefully when you see the picture it will make more sense.
> I'm not sure which exponential function to use but I
> imagine it will be a simple job to replace functions once
> the method is worked out, so choose a common one to start
> with.

You have not defined the desired
characteristics of the interpolant. In
fact, the curve in the figure does NOT
pass through zero in the middle of
each segment.

 
> I am only specifying the peak coordinates and that the y
> coord is 0 between each peak. I want to generate the data
> points between each peak and 0 to get something similar to
> the plot in the picture.

Again, the picture you uploaded does
not actually pass through zero.

So, what property do you want to see?

A true zero? Or something else?

John

Subject: interpolate

From: John D'Errico

Date: 2 Aug, 2008 00:23:03

Message: 6 of 7

"Dave Brackett" <davebrackett@hotmail.com> wrote in message
<g6vcoa$peq$1@fred.mathworks.com>...

> I am only specifying the peak coordinates and that the y
> coord is 0 between each peak. I want to generate the data
> points between each peak and 0 to get something similar to
> the plot in the picture.

I'll show some mercy. Assuming that you
don't really want to get 0 in between...

k = .1;
coef = exp(-abs(bsxfun(@minus,x,x')*k))\y;
xev = 0:1500;
pred = exp(-abs(bsxfun(@minus,xev',x')*k))*coef;
plot(xev,pred)

You can pick the value of k that gives you
the shape you want to see. I still don't see
why you want it, but thats your problem.

John

Subject: interpolate

From: Dave Brackett

Date: 13 Aug, 2008 13:06:02

Message: 7 of 7

"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <g709d7$eq$1@fred.mathworks.com>...
> "Dave Brackett" <davebrackett@hotmail.com> wrote in message
> <g6vcoa$peq$1@fred.mathworks.com>...
>
> > I am only specifying the peak coordinates and that the y
> > coord is 0 between each peak. I want to generate the data
> > points between each peak and 0 to get something similar to
> > the plot in the picture.
>
> I'll show some mercy. Assuming that you
> don't really want to get 0 in between...
>
> k = .1;
> coef = exp(-abs(bsxfun(@minus,x,x')*k))\y;
> xev = 0:1500;
> pred = exp(-abs(bsxfun(@minus,xev',x')*k))*coef;
> plot(xev,pred)
>
> You can pick the value of k that gives you
> the shape you want to see. I still don't see
> why you want it, but thats your problem.
>
> John

Indeed the plot in the picture does not go exactly to zero,
but as I said in the first post, the picture shows the 'kind
of thing' I want. It is actually unimportant in this case
whether it completely reaches zero or not. It just needs to
get close.

Thank you both for your help with this, I can achieve what I
need now.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us