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
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>...
Best regards
Mohamed
"Jiwu " <rig...@gmail.com> wrote in message <f84vk8$nn8$1...@fred.mathworks.com>...
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).
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
> > 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
Thank you very much John, your are precious!
I used gridfit and it resolves my problem!
Mohamed Hendawi