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:
interpolation question

Subject: interpolation question

From: Jonathan

Date: 8 Oct, 2012 16:27:08

Message: 1 of 6

Hi,

I have a cross-section and I'm trying to interpolate the cross-shore (i.e. x) location(s) given identified depths of interest. Is there a function in matlab that can do this? I've looked at interp1, but it's the reverse of what I am trying to do (i.e. interpolate y based on x-values).

Thanks
Jon

Subject: interpolation question

From: dpb

Date: 8 Oct, 2012 16:32:05

Message: 2 of 6

On 10/8/2012 11:27 AM, Jonathan wrote:
> Hi,
>
> I have a cross-section and I'm trying to interpolate the cross-shore
> (i.e. x) location(s) given identified depths of interest. Is there a
> function in matlab that can do this? I've looked at interp1, but it's
> the reverse of what I am trying to do (i.e. interpolate y based on
> x-values).

That's just a frame-of-reference...interp1() doesn't care which is the
independent vis a vis dependent variable...

--

Subject: interpolation question

From: Jonathan

Date: 8 Oct, 2012 16:39:08

Message: 3 of 6

dpb <none@non.net> wrote in message <k4uv60$qqq$1@speranza.aioe.org>...
> On 10/8/2012 11:27 AM, Jonathan wrote:
> > Hi,
> >
> > I have a cross-section and I'm trying to interpolate the cross-shore
> > (i.e. x) location(s) given identified depths of interest. Is there a
> > function in matlab that can do this? I've looked at interp1, but it's
> > the reverse of what I am trying to do (i.e. interpolate y based on
> > x-values).
>
> That's just a frame-of-reference...interp1() doesn't care which is the
> independent vis a vis dependent variable...
>
> --

I thought about that. However, when I reversed the order, Matlab gave me an error saying that the y-values needed to be monotonic.

Subject: interpolation question

From: dpb

Date: 8 Oct, 2012 16:50:01

Message: 4 of 6

On 10/8/2012 11:39 AM, Jonathan wrote:
...

>> That's just a frame-of-reference...interp1() doesn't care which is the
>> independent vis a vis dependent variable...
...

> I thought about that. However, when I reversed the order, Matlab gave me
> an error saying that the y-values needed to be monotonic.

Well, yes, you'll need to sort on the response (and keep the
corresponding order of the other data as well) but that should be no
problem...

Of course, if you've got a multi-valued response function you'll have to
do something different--like piecewise or fit an approximating function
or somesuch.

--

Subject: interpolation question

From: dpb

Date: 8 Oct, 2012 17:34:27

Message: 5 of 6

On 10/8/2012 11:50 AM, dpb wrote:
...

> Of course, if you've got a multi-valued response function you'll have to
> do something different--like piecewise or fit an approximating function
> or somesuch.
...

That is, consider if you had a response such as y=cx^2 and want to
inverse-interpolate from y to find x--which x do you want for a given
bracketed y value?

OTOH, if you constrain the interpolation to go from the minimum location
one way or the other, it's doable w/ simple interpolation such as interp1

If can't you've got to resort to some other technique but what would be
most likely candidate is dependent on the form of the data...

--

Subject: interpolation question

From: TideMan

Date: 8 Oct, 2012 20:35:46

Message: 6 of 6

On Tuesday, October 9, 2012 5:27:09 AM UTC+13, Jonathan wrote:
> Hi,
>
>
>
> I have a cross-section and I'm trying to interpolate the cross-shore (i.e. x) location(s) given identified depths of interest. Is there a function in matlab that can do this? I've looked at interp1, but it's the reverse of what I am trying to do (i.e. interpolate y based on x-values).
>
>
>
> Thanks
>
> Jon

For cross-section data, you need to think of it in a slightly different way.
What you have is a level represented by a horizontal line and you want to find where that line intersects the cross section.
So, if you subtract that level from the ordinates (y values), you will get a set of relative levels that are positive for points greater than your level and negative for those below.
Now, by finding the points where the sign changes, you will define the intervals where the level intersects the cross section.
So, you are looking for the places where the product:
p=rl(1:end-1)*rl(2:end);
indx=find(p < 0);
Now you have the locations of the intersections.
I'll leave the rest to you................

 

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