Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Out Of Memory after Griddata V4 method interpolation!

273 views
Skip to first unread message

medhtn

unread,
Jul 24, 2007, 9:22:56 AM7/24/07
to
Hi,
I'm using Matlab2007a, I'm using Windows XP, 1GB Ram,
I want to plot a contours map.
I have 3 vectors : x, y and z. length(x)=length(x)=length(x)=15000.
I need to interpolate z values on regular grid. So I'm using griddata:
[xi,yi]=meshgrid(-40:1:40);
zi=griddata(x,y,z,xi,yi,'v4'), I'm using V4 method because it seems the best method to make topography.
This method is very "expensive" and returns the "Out of memory" error! this errors occurs usually in the lines below (of the griddata matlab function) :
d = xy(:,ones(1,length(xy)));
d = abs(d - d.');
This errors seems as transposition problem since length(x)is much greater than 4000, because for vectors of 3000 elements around, the method works (but still very low).

Is there any technical size limitation of the griddata V4 method? if yes, what's the maximum length can one use? is there any way mend it?

Is there any other way to draw contours directly from 3 vector data (i.e. without the use of regular matrices)?

please find here an example:

x=rand(1,15000);
y=rand(1,15000);
z=-y.^2+x.^0.5;
[xi,yi]=meshgrid(0:0.01:1);
zi=griddata(x,y,z,xi,yi,'v4')

??? Out of memory. Type HELP MEMORY for your options.
Error in ==> griddata>gdatav4 at 252
d = xy(:,ones(1,length(xy)));
Error in ==> griddata at 119
zi = gdatav4(x,y,z,xi,yi);


Thanks fo help

Jiwu

unread,
Jul 24, 2007, 9:42:32 AM7/24/07
to
My experience with large griddata 2D interpolation is with 400,000+ points of X-Y-Z (in which Z is complex numbers). Of cause my PC has 4GB of RAM, and operation took 30+ seconds.

I did have problems in using GRIDDATA. One trick is to try to trim your data to nearest hundreds with n = int(n/100)*100) and X = X(1:n), etc. You can experiment a little

Also, you may want to increase the size of the virtual memory on your PC.

Hope this helps, and wish you luck.

Here is part of the script, similar to yours.
%%The GRIDDATA function is used to generate data on a uniform grid.
nx = 50; % I used also, 100 by 100 and 200 by 200
ny = 50;
% Create uniform grid
xa = floor(min(X)); xb = floor(max(X)); xc = (xb-xa)/nx;
ya = floor(min(Y)); yb = floor(max(Y)); yc = (yb-ya)/ny;
x = xa:xc:xb; y = ya:yc:yb;
[XI YI] = meshgrid(xa:xc:xb, ya:yc:yb);

ZI = griddata(X, Y, Z, XI, YI);
-----------------------------------------------------


"medhtn " <med...@yahoo.fr> wrote in message <f84ufg$66h$1...@fred.mathworks.com>...

medhtn

unread,
Jul 24, 2007, 10:30:41 AM7/24/07
to
thanks Jiwu for your response.
My problem still about the X, Y and Z size, not about xi and yi size.
I didn't understand the trim: n = int(n/100)*100), what's n?

Best regards
Mohamed


"Jiwu " <rig...@gmail.com> wrote in message <f84vk8$nn8$1...@fred.mathworks.com>...

medhtn

unread,
Jul 24, 2007, 6:31:33 PM7/24/07
to
Any help?

medhtn

unread,
Jul 25, 2007, 6:26:43 AM7/25/07
to
Hi, I post my problem again, if any one can help!
thanks in advance,

I'm using Matlab2007a, I'm using Windows XP, 1GB Ram,
I want to plot a contours map.
I have 3 vectors : x, y and z. length(x)=length(x)=length(x)=15000.
I need to interpolate z values on regular grid. So I'm using griddata:
[xi,yi]=meshgrid(-40:1:40);
zi=griddata(x,y,z,xi,yi,'v4'), I'm using V4 method because it seems the best method to make topography.
This method is very "expensive" and returns the "Out of memory" error! this errors occurs usually in the lines below (of the griddata matlab function) :

d = xy(:,ones(1,length(xy)));
d = abs(d - d.');

This errors seems as transposition problem since length(x)is much greater than 4000, because for vectors of 3000 elements around, the method works (but still very low).

the pbme is because the length of x, y and z (about 15000), there is no problem about the length of xi and yi(about 100).

Steven Lord

unread,
Jul 25, 2007, 2:43:02 PM7/25/07
to

"medhtn " <med...@yahoo.fr> wrote in message
news:f878h3$3l0$1...@fred.mathworks.com...

> Hi, I post my problem again, if any one can help!
> thanks in advance,
>
> I'm using Matlab2007a, I'm using Windows XP, 1GB Ram,
> I want to plot a contours map.
> I have 3 vectors : x, y and z. length(x)=length(x)=length(x)=15000.
> I need to interpolate z values on regular grid. So I'm using griddata:
> [xi,yi]=meshgrid(-40:1:40);
> zi=griddata(x,y,z,xi,yi,'v4'), I'm using V4 method because it seems the
> best method to make topography.
> This method is very "expensive" and returns the "Out of memory" error!
> this errors occurs usually in the lines below (of the griddata matlab
> function) :
>
> d = xy(:,ones(1,length(xy)));
> d = abs(d - d.');
>
> This errors seems as transposition problem since length(x)is much greater
> than 4000, because for vectors of 3000 elements around, the method works
> (but still very low).

That first statement is trying to create a 15000 by 15000 matrix. This
matrix takes up about 1.7 GB of memory. Even if you had that much memory
available, the calculation on the next line requires even more memory for
the result d-d'.

> the pbme is because the length of x, y and z (about 15000), there is no
> problem about the length of xi and yi(about 100).
>
> Is there any technical size limitation of the griddata V4 method? if yes,
> what's the maximum length can one use? is there any way mend it?

No, but you're limited by the amount of memory available to MATLAB. Try
using a different method -- each of 'linear', 'cubic', and 'nearest' worked
fine on your example below.

> Is there any other way to draw contours directly from 3 vector data (i.e.
> without the use of regular matrices)?

No, not as far as I know.

*snip example*

--
Steve Lord
sl...@mathworks.com


John D'Errico

unread,
Jul 31, 2007, 4:27:49 AM7/31/07
to
In article <f885jm$d4g$1...@fred.mathworks.com>, "Steven Lord" <sl...@mathworks.com> wrote:

> > Is there any other way to draw contours directly from 3 vector data (i.e.
> > without the use of regular matrices)?
>
> No, not as far as I know.

Actually, one way to do so is to use gridfit,
found on the file exchange.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8998

One of the examples I provide starts with
sampled data points i took from a topo map
(of a hillside in upstate NY) then converted
to a surface using gridfit.

John


--
The best material model of a cat is another, or preferably the same, cat.
A. Rosenblueth, Philosophy of Science, 1945

Those who can't laugh at themselves leave the job to others.
Anonymous

medhtn

unread,
Aug 2, 2007, 6:45:06 AM8/2/07
to
John D'Errico <wood...@rochester.rr.com> wrote in message <woodchips-5A51D...@news.rochester.rr.com>...

Thank you very much John, your are precious!
I used gridfit and it resolves my problem!
Mohamed Hendawi

0 new messages