Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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 ]
hanciong awesome

Posts: 21
Registered: 1/11/12
how to make input size the same as output in interp2
Posted: Jan 25, 2013 12:34 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello all, I have a problem. I have the following scipt to make 2D interpolation of some function fu(x,y) = x^2y-y^2x. There is no problem if both x and y are scalars. However, if I call fuint with x scalar and y row vector for example, the output is column vector. also, if I call fuint with x column vector and y scalar, the output is row vector. see the two lines in which I write comment %-->problem here. The problem is that, quadgk can't integrate @(y) fuint(3,y), because input size is not the same as output. 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 ==========================================

clear all

xcoba = linspace(-5,5,50); ycoba = linspace(-5,5,50);

fu = @(x,y) x.^2.*y - y.^2.*x;

[xgrid,ygrid] = ndgrid(xcoba,ycoba);

fugrid = fu(xgrid,ygrid);

fuint = @(x,y) interp2(xgrid',ygrid',fugrid',x,y,'cubic',NaN);

fuint(1,[2,3,4]) %--> problem here

fuint([2;3;4],1) %--> problem here

quadgk(@(y) fuint(3,y), -3,3)

=======================================



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.