
Re: how to make input size the same as output in interp2
Posted:
Mar 7, 2013 3:37 PM


But then what should I do if I want to integrate this interpolation function? The quad2d or integral2 or whatever make input of x and y arbitrarily; I can't force them to expand x input or y input to have same size.
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <kdus7o$9he$1@newscl01ah.mathworks.com>... > "hanciong" wrote in message <kdufmg$ha6$1@newscl01ah.mathworks.com>... > >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); > > Therefore > 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]) > fuint([2;3;4],[1;1;1]) > > % Bruno

