http://www.mathworks.com/matlabcentral/newsreader/view_thread/324832
MATLAB Central Newsreader  2d data interpolation
Feed for thread: 2d data interpolation
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Thu, 29 Nov 2012 15:21:09 +0000
2d data interpolation
http://www.mathworks.com/matlabcentral/newsreader/view_thread/324832#892712
Giuseppe
Hi<br>
I have a problem with the function interp2: I have a matrx 100x3 where the first column is the xcoordinate, the second column is the ycoordinate and the third column is the value at the coordinates x and y.<br>
I would like to interpolate those values with a grid 600x600 but the x and y coordinates are not monotonic vectors and interp2 gives me an error.<br>
<br>
Can anyone help me?<br>
<br>
Many thanks<br>
Giuseppe

Thu, 29 Nov 2012 15:30:14 +0000
Re: 2d data interpolation
http://www.mathworks.com/matlabcentral/newsreader/view_thread/324832#892714
Justin Ashmall
"Giuseppe" wrote in message <k97uh5$9t7$1@newscl01ah.mathworks.com>...<br>
> Hi<br>
> I have a problem with the function interp2: I have a matrx 100x3 where the first column is the xcoordinate, the second column is the ycoordinate and the third column is the value at the coordinates x and y.<br>
> I would like to interpolate those values with a grid 600x600 but the x and y coordinates are not monotonic vectors and interp2 gives me an error.<br>
> <br>
> Can anyone help me?<br>
<br>
Show us what you've already tried (and what doesn't work)...

Fri, 30 Nov 2012 07:23:15 +0000
Re: 2d data interpolation
http://www.mathworks.com/matlabcentral/newsreader/view_thread/324832#892737
Giuseppe
Yes, sure, these are the command lines<br>
(cen_x is the vector with the xcoordinates, cen_y with the ycoordinates and in dd there are the values I want to interpolate. All of them are vectors with the same length)<br>
<br>
[Xi, Yi] = meshgrid(0:600);<br>
Zi = interp2(cen_x, cen_y, dd, Xi, Yi);<br>
figure, mesh(Xi, Yi, Zi);<br>
<br>
When I run these lines, I have the message:<br>
<br>
??? Error using ==> interp2 at 180<br>
X and Y must be monotonic vectors or matrices produced by MESHGRID.<br>
<br>
Error in ==> trial at 12<br>
Zi = interp2(cen_x, cen_y, dd, Xi, Yi);<br>
<br>
and I know that cen_x and cen_y are not monotonic, but they can't be monotonic because they are discrete points coming from other lines and, even if I force cen_x to be monotonic, cen_y is not like that.<br>
<br>
Thank you again<br>
Giuseppe

Fri, 30 Nov 2012 14:37:40 +0000
Re: 2d data interpolation
http://www.mathworks.com/matlabcentral/newsreader/view_thread/324832#892757
Steven_Lord
<br>
<br>
"Giuseppe " <giuseppe.zito@artorg.unibe.ch> wrote in message <br>
news:k99mt3$16l$1@newscl01ah.mathworks.com...<br>
> Yes, sure, these are the command lines<br>
> (cen_x is the vector with the xcoordinates, cen_y with the ycoordinates <br>
> and in dd there are the values I want to interpolate. All of them are <br>
> vectors with the same length)<br>
><br>
> [Xi, Yi] = meshgrid(0:600);<br>
> Zi = interp2(cen_x, cen_y, dd, Xi, Yi);<br>
> figure, mesh(Xi, Yi, Zi);<br>
><br>
> When I run these lines, I have the message:<br>
><br>
> ??? Error using ==> interp2 at 180<br>
> X and Y must be monotonic vectors or matrices produced by MESHGRID.<br>
<br>
That's correct. The INTERP2 function interpolates a function whose values <br>
are known on a regular grid to scattered points. If you want to interpolate <br>
a function whose values are known at scattered points, look at GRIDDATA.<br>
<br>
<a href="http://www.mathworks.com/help/matlab/ref/griddata.html">http://www.mathworks.com/help/matlab/ref/griddata.html</a><br>
<br>
 <br>
Steve Lord<br>
slord@mathworks.com<br>
To contact Technical Support use the Contact Us link on <br>
<a href="http://www.mathworks.com">http://www.mathworks.com</a>

Sat, 01 Dec 2012 09:52:08 +0000
Re: 2d data interpolation
http://www.mathworks.com/matlabcentral/newsreader/view_thread/324832#892835
Giuseppe
Yes, you're right! Now it's working!!<br>
Many thanks for your help.<br>
<br>
Cheers<br>
Giuseppe

Wed, 24 Apr 2013 04:24:42 +0000
Re: 2d data interpolation
http://www.mathworks.com/matlabcentral/newsreader/view_thread/324832#903052
fviolitta@gmail.com
On Saturday, December 1, 2012 1:52:08 AM UTC8, Giuseppe wrote:<br>
> Yes, you're right! Now it's working!!<br>
> <br>
> Many thanks for your help.<br>
> <br>
> <br>
> <br>
> Cheers<br>
> <br>
> Giuseppe<br>
<br>
Hi, will the griddata interpolate values just like when we are using interp2? Thanks.