matlab函数grid,matlab中griddata函数怎么用

matlab函数grid,matlab中griddata函数怎么用dbb627的回答:知道一系列点的坐标如下(1.486,3.059,0.1);(2.121,4.041,0.1);(2.570,3.959,0.1);(3.439,4.396,0.1);(4.505,3.012,0.1);(3.402,1.604,0.1);(2.570,2.065,0.1);(2.150,1.970,0.1);(1.794,3.059,0.2);(2.121,3.615,0.2)…

dbb627的回答:

知道一系列点的坐标如下(1.486,3.059,0.1);(2.121,4.041,0.1);(2.570,3.959,0.1);(3.439,4.396,0.1);(4.505,3.012,0.1);(3.402,1.604,0.1);(2.570,2.065,0.1);(2.150,1.970,0.1);(1.794,3.059,0.2);(2.121,3.615,0.2);(2.570,3.473,0.2);(3.421,4.160,0.2);(4.271,3.036,0.2);(3.411,1.876,0.2);(2.561,2.562,0.2);(2.179,2.420,0.2);(2.757,3.024,0.3);(3.439,3.970,0.3);(4.084,3.036,0.3);(3.402,2.077,0.3);(2.879,3.036,0.4);(3.421,3.793,0.4);(3.953,3.036,0.4);(3.402,2.219,0.4);(3.000,3.047,0.5);(3.430,3.639,0.5);(3.822,3.012,0.5);(3.411,2.385,0.5);(3.103,3.012,0.6);(3.430,3.462,0.6);(3.710,3.036,0.6);(3.402,2.562,0.6);(3.224,3.047,0.7);(3.411,3.260,0.7);(3.542,3.024,0.7);(3.393,2.763,0.7)怎样用MATLAB绘制成三维曲面呢?

使用griddata插值

A=[1.486,3.059,0.1;2.121,4.041,0.1;2.570,3.959,0.1;3.439,4.396,0.1;

4.505,3.012,0.1;3.402,1.604,0.1;2.570,2.065,0.1;2.150,1.970,0.1;

1.794,3.059,0.2;2.121,3.615,0.2;2.570,3.473,0.2;3.421,4.160,0.2;

4.271,3.036,0.2;3.411,1.876,0.2;2.561,2.562,0.2;2.179,2.420,0.2;

2.757,3.024,0.3;3.439,3.970,0.3;4.084,3.036,0.3;3.402,2.077,0.3;

2.879,3.036,0.4;3.421,3.793,0.4;3.953,3.036,0.4;3.402,2.219,0.4;

3.000,3.047,0.5;3.430,3.639,0.5;3.822,3.012,0.5;3.411,2.385,0.5;

3.103,3.012,0.6;3.430,3.462,0.6;3.710,3.036,0.6;3.402,2.562,0.6;

3.224,3.047,0.7;3.411,3.260,0.7;3.542,3.024,0.7;3.393,2.763,0.7];

x=A(:,1);y=A(:,2);z=A(:,3);

scatter(x,y,5,z)%散点图

figure

[X,Y,Z]=griddata(x,y,z,linspace(1.486,4.271)’,linspace(1.604,4.276),’v4′);%插值

pcolor(X,Y,Z);shading interp%伪彩色图

figure,contourf(X,Y,Z) %等高线图

figure,surf(X,Y,Z)%三维曲面

ssilspro的回答:

x = rand(1,12);

y = rand(1,12);

z = rand(1,12); % now use some random z axis data

xi = linspace(min(x),max(x),30);% x interpolation points

yi = linspace(min(y),max(y),30);% x interpolation points

[Xi,Yi] = meshgrid(xi,yi);% create grid of x and y

Zi = griddata(x,y,z,Xi,Yi);% grid the data at Xi,Yi points

% Zi = griddata(x,y,z,Xi,Yi, ‘linear’)% same as above(default)

% Zi = griddata(x,y,z,Xi,Yi, ‘cubic’)% triangle based cubic interpolation

% Zi = griddata(x,y,z,Xi,Yi, ‘nearest’)% triangle based nearest neighbor

% Zi = griddata(x,y,z,Xi,Yi, ‘invdist’)% inverse distance method

mesh(Xi,Yi,Zi)

hold on

plot3(x,y,z, ‘ko’)% show original data as well

hold off

title(‘Figure 18.10: Griddata Example’)

堵禹白飞翼的回答:

MATLAB散乱点插值函数

griddata函数

语法:

ZI

=

griddata(x,y,z,XI,YI)

[XI,YI,ZI]

=

griddata(x,y,z,XI,YI)

[…]

=

griddata(…,method)

[…]

=

griddata(…,method,options)

说明:

ZI

=

griddata(x,y,z,XI,YI)

调整形如z

=

f(x,y)的曲面,使之与非等间距矢量(x,y,z)中的数据吻合。griddata

函数在指定的(XI,YI)点处插补此曲面,生成ZI.

此曲面一定通过这些数据点。

XI

YI

通常构成均匀网格(与meshgrid函数生成的相同).

XI

可以是行矢量,这种情况下该矢量确定一个具有固定列数的矩阵。与之类似,YI

可以是列矢量,确定一个具有固定行数的矩阵。

[XI,YI,ZI]

=

griddata(x,y,z,XI,YI)

函数返回与上述矩阵相同的插补后的矩阵ZI。并返回由行矢量XI和列矢量yi形成的矩阵XI

和YI.

后者与meshgrid

函数返回的矩阵相同。

[…]

=

griddata(…,method)使用规定的插补方法:

‘linear’

基于三角形的线性插补法(缺省)

‘cubic’

基于三角形的三次插补法

‘nearest’

最近邻居插补法

‘v4’

MATLAB

griddata方法。

这些方法定义了匹配数据点的曲面类型。’cubic’

‘v4’

方法生成平滑曲面,而

‘linear’

‘nearest’

分别具有一阶导数和零阶导数不连续。除’v4′

外所有方法基于数据的三角化。如果方法为[],

则使用缺省的’linear’

方法。

[…]

=

griddata(…,method,options)指定一串将通过delaunayn函数在Qhull中使用的单元阵列选项.

如果选项为

[],

则使用缺省的三角化选项。如果选项为{”},

不使用任何选项,包括缺省选项。有时,griddata

函数可能将位于数据凸壳上或靠近凸壳的点返回为NaNs。这是因为有时计算中的圆整处理使得很难确定一个靠近边界的点是否处于凸壳内。

算法:

griddata(…,’v4′)

命令使用

[3]

中文档化的方法。其他griddata方法基于使用Qhull

[2]

的数据三角化。

实例:

对一个函数在±2.0范围内随机采样100点:

rand(‘seed’,0)

x

=

rand(100,1)*4-2;

y

=

rand(100,1)*4-2;

z

=

x.*exp(-x.^2-y.^2);

x,

y,

z

均为包含非均匀采样数据的矢量。定义一个规范的网格,将数据与网格匹配:

ti

=

-2:.25:2;

[XI,YI]

=

meshgrid(ti,ti);

ZI

=

griddata(x,y,z,XI,YI);

Plot

the

gridded

data

along

with

the

nonuniform

data

points

used

to

generate

it:

mesh(XI,YI,ZI),

hold

plot3(x,y,z,’o’),

hold

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:http://bianchenghao.cn/35853.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注