The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: how to make input size the same as output in interp2
Replies: 4   Last Post: May 4, 2013 6:48 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 9,822
Registered: 7/26/08
Re: how to make input size the same as output in interp2
Posted: Jan 25, 2013 4:08 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"hanciong" wrote in message <kdufmg$ha6$>...
>how should I modify this such that the size of the output is the same as input, if either x or y is scalar? Thanx

You can't. When calling interp2(..., x, y); with the interpolation points x and y are scalar/vectors with different sizes, the inputs x and y are first expanded on grid as following:

[X Y] = meshgrid(x(:),y(:)) % x varying 2nd dimension and x first
z = interp2(..., X, Y);

1) if x is scalar, the output is vertical regardless y;
2) if y is scalar, the output is horizontal regardless x.

This behavior is documented.

If you want to force the result to be horizontal or vertical vectors, you must expand x, y in the same size:

fuint([1 1 1],[2,3,4])

% Bruno

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.