Thread Subject: interp3 question?

Subject: interp3 question?

From: Hydroman S

Date: 9 Jun, 2008 03:58:01

Message: 1 of 11

I have a set of points; say D1 (3x1), Each of these points
is assigned a matrix, F (20 x 3).

I also have another set of points, say D2 (4 x 1), how can
I interpolate I wish to interpolate F over the set D2.

I looked up interp3 and griddatan, but was not able to
accomplish my goal, any tips?

Subject: interp3 question?

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

Date: 9 Jun, 2008 04:23:47

Message: 2 of 11

In article <g2i9o9$qsu$1@fred.mathworks.com>,
Hydroman S <amirgsalem@gmail.com> wrote:
>I have a set of points; say D1 (3x1), Each of these points
>is assigned a matrix, F (20 x 3).

>I also have another set of points, say D2 (4 x 1), how can
>I interpolate I wish to interpolate F over the set D2.

Perhaps if you gave an example of your data structures?
Most of what you say has left me uncertain about what you want to
do, but rather than point out the possible interpretations, it
would be easier if you gave an example.
--
  "After all, what problems has intellectualism ever solved?"
                                              -- Robert Gilman

Subject: interp3 question?

From: Hydroman S

Date: 9 Jun, 2008 04:34:01

Message: 3 of 11

the example:

D1=rand(3,1);
F=rand(20,3);
D2=rand(4,1);

and I wish to interpolate F over the set D2.



I tried:

interp1((meshgrid(D1,ones(1,length(F)))),F,D2), but I get
the error: ??? Error using ==> interp1
The values of X should be distinct.


Subject: interp3 question?

From: Hydroman S

Date: 9 Jun, 2008 05:09:01

Message: 4 of 11

I also tried interp3 and griddatan to account for the
dimensionality of F, but I also ended up with errors.

Subject: interp3 question?

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

Date: 9 Jun, 2008 07:40:52

Message: 5 of 11

In article <g2ibrp$at0$1@fred.mathworks.com>,
Hydroman S <amirgsalem@gmail.com> wrote:
>the example:

>D1=rand(3,1);
>F=rand(20,3);
>D2=rand(4,1);

Your original question said that *each* of the points in D1 was
assigned a 20 x 3 matrix, F, but in this example, there is only
-one- 20 x 3 matrix.

Is each row of D1 associated with a single column of F?
So D1(2) is associated with F(:,2) ? And for any particular D2(K),
you are expecting to produce 20 output values?

Are the rows of F independant of each other, or is there some kind
of cross-correlation between the rows?
--
  "Pray do not take the pains / To set me right. /
   In vain my faults ye quote; / I wrote as others wrote /
   On Sunium's hight." -- Walter Savage Landor

Subject: interp3 question?

From: John D'Errico

Date: 9 Jun, 2008 08:53:01

Message: 6 of 11

"Hydroman S" <amirgsalem@gmail.com> wrote in message
<g2i9o9$qsu$1@fred.mathworks.com>...
> I have a set of points; say D1 (3x1), Each of these points
> is assigned a matrix, F (20 x 3).
>
> I also have another set of points, say D2 (4 x 1), how can
> I interpolate I wish to interpolate F over the set D2.
>
> I looked up interp3 and griddatan, but was not able to
> accomplish my goal, any tips?
>

You have three points, in a one dimensional
domain space, that map to three function
values. So you use interp1. It so happens that
you have 20 of these relationships to interpolate,
and conveniently for you, interp1 will do them
all in one call. Try it.

You do not have an n-dimensional problem
that needs a high dimensional interpolation.

Use interp1.

John

Subject: interp3 question?

From: Hydroman S

Date: 9 Jun, 2008 11:54:02

Message: 7 of 11

Thanks Walter and John.

Walter:

> Is each row of D1 associated with a single column of F?

Yes.

> So D1(2) is associated with F(:,2) ?

yes.


And for any particular D2(K),
> you are expecting to produce 20 output values?

Yes.


>
> Are the rows of F independant of each other, or is there
some kind
> of cross-correlation between the rows?

Yes the rows of F are independant of each other.



roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <g2imq4$hd$1@canopus.cc.umanitoba.ca>...
> In article <g2ibrp$at0$1@fred.mathworks.com>,
> Hydroman S <amirgsalem@gmail.com> wrote:
> >the example:
>
> >D1=rand(3,1);
> >F=rand(20,3);
> >D2=rand(4,1);
>
> Your original question said that *each* of the points in
D1 was
> assigned a 20 x 3 matrix, F, but in this example, there
is only
> -one- 20 x 3 matrix.
>
> Is each row of D1 associated with a single column of F?
> So D1(2) is associated with F(:,2) ? And for any
particular D2(K),
> you are expecting to produce 20 output values?
>
> Are the rows of F independant of each other, or is there
some kind
> of cross-correlation between the rows?
> --
> "Pray do not take the pains / To set me right. /
> In vain my faults ye quote; / I wrote as others
wrote /
> On Sunium's hight." -- Walter
Savage Landor

Subject: interp3 question?

From: John D'Errico

Date: 9 Jun, 2008 12:12:02

Message: 8 of 11

"Hydroman S" <amirgsalem@gmail.com> wrote in message
<g2j5kq$4cl$1@fred.mathworks.com>...
> Thanks Walter and John.
>
> Walter:
>
> > Is each row of D1 associated with a single column of F?
>
> Yes.
>
> > So D1(2) is associated with F(:,2) ?
>
> yes.
>
>
> And for any particular D2(K),
> > you are expecting to produce 20 output values?
>
> Yes.
>
>
> >
> > Are the rows of F independant of each other, or is there
> some kind
> > of cross-correlation between the rows?
>
> Yes the rows of F are independant of each other.

Then read my response. Use interp1.

John

Subject: interp3 question?

From: Hydroman S

Date: 9 Jun, 2008 12:14:02

Message: 9 of 11

John, are you sugessting interpolating over each row of F
in a loop:

for i=1:length (F)
FNEW(i,:)=interp1(D1,F(i,:),D2')
end




"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <g2ir1d$bh9$1@fred.mathworks.com>...
> "Hydroman S" <amirgsalem@gmail.com> wrote in message
> <g2i9o9$qsu$1@fred.mathworks.com>...
> > I have a set of points; say D1 (3x1), Each of these
points
> > is assigned a matrix, F (20 x 3).
> >
> > I also have another set of points, say D2 (4 x 1), how
can
> > I interpolate I wish to interpolate F over the set
D2.
> >
> > I looked up interp3 and griddatan, but was not able to
> > accomplish my goal, any tips?
> >
>
> You have three points, in a one dimensional
> domain space, that map to three function
> values. So you use interp1. It so happens that
> you have 20 of these relationships to interpolate,
> and conveniently for you, interp1 will do them
> all in one call. Try it.
>
> You do not have an n-dimensional problem
> that needs a high dimensional interpolation.
>
> Use interp1.
>
> John

Subject: interp3 question?

From: John D'Errico

Date: 9 Jun, 2008 12:26:01

Message: 10 of 11

"Hydroman S" <amirgsalem@gmail.com> wrote in message
<g2j6qa$gd2$1@fred.mathworks.com>...
> John, are you sugessting interpolating over each row of F
> in a loop:
>
> for i=1:length (F)
> FNEW(i,:)=interp1(D1,F(i,:),D2')
> end

No. I never said that, although you could
do so. I did state this...

> It so happens that
> you have 20 of these relationships to interpolate,
> and conveniently for you, interp1 will do them
> all in one call. Try it.

Does nobody ever believe me? Why would I lie?

interp1(linspace(0,1,5)',rand(5,6),rand(3,1))
ans =
      0.77177 0.14707 0.76589 0.81177 0.56821 0.21676
       0.8487 0.57487 0.13975 0.57749 0.20276 0.34827
      0.85734 0.51283 0.13816 0.69665 0.14793 0.37811

A one dimensional problem, but here with
6 outputs.

By the way, if you are seriously interpolating
with only three data points, don't expect a
terribly good prediction.

John

Subject: interp3 question?

From: Hydroman S

Date: 9 Jun, 2008 12:47:01

Message: 11 of 11

this works, thanks John. I'm a believer now :)

I guess what was confusing me is that the length of D had
to be equal to the # of columns in F as you show in your
example:

interp1(linspace(0,1,5)',rand(5,6),rand(3,1))

Tags for this Thread

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com