From: Wei on
Hi guys,
I just started to use matlab. I got the *out of memory* error while I used the following commands:
load out.txt
[X,Y]=meshgrid(out(:,1),out(:,2));
Z=griddata(out(:,1),out(:,2),out(:,3),X,Y);
surf(X,Y,Z);
the out.txt is smaller than 300kb. And I am pretty sure that the memory available is big enough. Although I am not so sure how to check it. It would be great if someone could help me to find it out and solve this problem.
Thanks a lot.

wei
From: Matt Fig on
How many elements are in the 'out' variable? If it is N-by-3, then you should be aware that X,Y,Z are all N-by-N. If N is very large, it is easy to see why you get such an error. You may need to filter, for example:

out = out(1:2:end,:)
[X,Y] = ....

since you surf plot may not need such fine detail if N is very large.
From: Wei on
Hi Matt,
Thanks for your reply.
There are indeed N-by-3 elements in the out. I guess you have pointed out why would I have this problem. But I tried the filter you mentioned like below:
load out.txt
out = out(1:2:end,:);
[X,Y]=meshgrid(out(:,1),out(:,2));

it still gave me the *out of memory* error. Could you help me to figure it out, please?
Thank you very much.

wei
From: Walter Roberson on
Wei wrote:

> I just started to use matlab. I got the *out of memory* error while I
> used the following commands:
> load out.txt
> [X,Y]=meshgrid(out(:,1),out(:,2));
> Z=griddata(out(:,1),out(:,2),out(:,3),X,Y);
> surf(X,Y,Z);

You do not need to create the grid for the purposes of griddata or surf:

load out.txt
z = griddata(out(:,1),out(:,2),out(:,3),out(:,1),out(:,2));
surf(out(:,1),out(:,2),Z);
From: Wei on
Hi Walter,
Thanks a lot for your attention.
But I think if we want to use mesh or surf, we need to create our meshgrid, as
iin regular 2D plot when we want to plot sth against sth, right?
Anyway, I tried your way. I just got an empty plot...