## Using three 60000 x 1 double matrices, how to make the 3D graph efficiently in the form of 2D

SAMET YILDIZ

### SAMET YILDIZ (view profile)

さんによって質問されました 2014 年 7 月 11 日

### SAMET YILDIZ (view profile)

さんによって コメントされました 2014 年 7 月 25 日
Kelly Kearney

### Kelly Kearney (view profile)

さんの 回答が採用されました
Hello, Simply, I need to make use 3 matrices which are 60000 x 1 size each. When I use the code below, I have a serious performance problem and I cannot complete the meshgrid because of the large matrices. How can I implement what I need to do? Thanks
clc
clear all
a=rand(60000,1);
b=rand(60000,1);
c=rand(60000,1);
[X,Y]=meshgrid(a,b);
Z=griddata(a,b,c,X,Y,'cubic');
mesh(X,Y,Z)

#### 0 件のコメント

サインイン to comment.

## 1 件の回答

### Kelly Kearney (view profile)

2014 年 7 月 11 日
採用された回答

Right now, your meshgird command is attempting to create 2 60000x60000 matrices... which are going to require around 26 GB each. However, luckily, that's not actually what you want to do.
Is your real data actually completely scattered, as in this example? Or does it already lie on a grid, but is simply stored in vectors?
If it's truly scattered:
F = scatteredInterpolant(x,y,z);
[x,y] = meshgrid(linspace(min(a),max(a),100), linspace(min(b),max(b),100));
z = F(x,y);
mesh(x,y,z);
If it lies on a grid already, you can eliminate the triagulation and simply rearrange your data into the appropriate grids.

Kelly Kearney

### Kelly Kearney (view profile)

2014 年 7 月 11 日
The edge effects are probably due to extrapolation. By default, scatteredInterpolant performs linear interpolation and extrapolation, and linear extrapolation can run away like that if your edge points are noisy. You might want to try nearest neighbor extrapolation instead:
F = scatteredInterpolant(x,y,'linear','nearest');
SAMET YILDIZ

### SAMET YILDIZ (view profile)

2014 年 7 月 25 日
Thank you, it helped a lot

サインイン to comment.

Translated by