Thread Subject: Interpolating between 2 columns

Subject: Interpolating between 2 columns

From: Jason

Date: 25 Feb, 2008 16:57:02

Message: 1 of 5

Hello,

I have two columns of data

X1 = 20 21 22 23 at 2

X2 = 30 31 32 33 at 3

I want the column of data at 2.5. I'm not sure how to obtain
this using interp commands.

Thanks in advance.

Subject: Interpolating between 2 columns

From: John D'Errico

Date: 25 Feb, 2008 17:31:02

Message: 2 of 5

"Jason " <j_henderson44@REMOVEhotmail.com> wrote in message
<fpus0u$pgs$1@fred.mathworks.com>...
> Hello,
>
> I have two columns of data
>
> X1 = 20 21 22 23 at 2
>
> X2 = 30 31 32 33 at 3
>
> I want the column of data at 2.5. I'm not sure how to obtain
> this using interp commands.
>
> Thanks in advance.

Z = [10 11 12 13;20 21 22 23;30 31 32 33]';

z25 = interp2(1:3,1:4,Z,2.5,1:4)
z25 =
    25
    26
    27
    28

HTH,
John

Subject: Interpolating between 2 columns

From: Jason

Date: 26 Feb, 2008 09:15:03

Message: 3 of 5

"John D'Errico" <woodchips@rochester.rr.com> wrote in
>
> Z = [10 11 12 13;20 21 22 23;30 31 32 33]';
>
> z25 = interp2(1:3,1:4,Z,2.5,1:4)
> z25 =
> 25
> 26
> 27
> 28
>
> HTH,
> John

John,

Thank you for the answer. I should learn to post the more
difficult part of the problem from the start on here ;-) I
always start from a simple problem to understand what is
happening.

I see you have added an additional row to give the
interpolation matrix that is equally spaced between columns.

My real problem is that:

my column data is not equally spaced as your additional
column makes it.

ie X1 = [20 21 22 23] at 17

   X2 = [30 31 32 33] at 20

Jason

Subject: Interpolating between 2 columns

From: Jason

Date: 26 Feb, 2008 10:35:03

Message: 4 of 5

"Jason " <j_henderson44@REMOVEhotmail.com> wrote in message
<fq0lan$k11$1@fred.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in
> >
> > Z = [10 11 12 13;20 21 22 23;30 31 32 33]';
> >
> > z25 = interp2(1:3,1:4,Z,2.5,1:4)
> > z25 =
> > 25
> > 26
> > 27
> > 28
> >
> > HTH,
> > John
>
> John,
>
> Thank you for the answer. I should learn to post the more
> difficult part of the problem from the start on here ;-) I
> always start from a simple problem to understand what is
> happening.
>
> I see you have added an additional row to give the
> interpolation matrix that is equally spaced between columns.
>
> My real problem is that:
>
> my column data is not equally spaced as your additional
> column makes it.
>
> ie X1 = [20 21 22 23] at 17
>
> X2 = [30 31 32 33] at 20
>
> Jason

Ok sorry for the question above. I guess I just need to
redefine the input value as a fraction of 2 and 3. Is this
the best/most logical way? It works but I am keen to follow
good convention.

Z = [20 21 22 23;30 31 32 33]';
 
z25 = interp2(1:2,1:4,Z,fraction,1:4)

Jason

Subject: Interpolating between 2 columns

From: John D'Errico

Date: 26 Feb, 2008 13:00:18

Message: 5 of 5

"Jason " <j_henderson44@REMOVEhotmail.com> wrote in message
<fq0q0n$hn$1@fred.mathworks.com>...
> "Jason " <j_henderson44@REMOVEhotmail.com> wrote in message
> <fq0lan$k11$1@fred.mathworks.com>...
> > "John D'Errico" <woodchips@rochester.rr.com> wrote in
> > >
> > > Z = [10 11 12 13;20 21 22 23;30 31 32 33]';
> > >
> > > z25 = interp2(1:3,1:4,Z,2.5,1:4)
> > > z25 =
> > > 25
> > > 26
> > > 27
> > > 28
> > >
> > > HTH,
> > > John
> >
> > John,
> >
> > Thank you for the answer. I should learn to post the more
> > difficult part of the problem from the start on here ;-) I
> > always start from a simple problem to understand what is
> > happening.
> >
> > I see you have added an additional row to give the
> > interpolation matrix that is equally spaced between columns.
> >
> > My real problem is that:
> >
> > my column data is not equally spaced as your additional
> > column makes it.
> >
> > ie X1 = [20 21 22 23] at 17
> >
> > X2 = [30 31 32 33] at 20
> >
> > Jason
>
> Ok sorry for the question above. I guess I just need to
> redefine the input value as a fraction of 2 and 3. Is this
> the best/most logical way? It works but I am keen to follow
> good convention.
>
> Z = [20 21 22 23;30 31 32 33]';
>
> z25 = interp2(1:2,1:4,Z,fraction,1:4)

Interp2 does not need equal spacing, and
I could have written it with only two columns.
I misinterpreted your original question, so
for some silly reason I added a column.

Z = [20 21 22 23;30 31 32 33]';
z25 = interp2([17 20],1:4,Z,18.5,1:4)

John

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
interpolation Jason 25 Feb, 2008 12:00:09
rssFeed for this Thread

Contact us at files@mathworks.com