八度3d图与网格实验数据

问题描述 投票:1回答:1

我有以下问题。我有一张表格,其中包含在矩阵A(a,b,c)中读取的实验数据,如下所示:

4.00000   7.00000   0.09035
4.00000   6.00000   0.02632
4.00000   5.00000   0.01184
4.00000   4.00000   0.30728
4.00000   3.00000   0.16022
4.00000   2.00000   0.01734
3.00000   6.00000   0.05817
3.00000   5.00000   0.02296
3.00000   4.00000   0.00000
3.00000   3.00000   0.22576
3.00000   2.00000   0.08331
3.00000   1.50000   0.00297
2.00000   6.00000   0.00000
2.00000   5.00000   0.05184
2.00000   4.00000   0.01883
2.00000   3.00000   0.00000
2.00000   2.00000   0.10719
2.00000   1.50000   0.06689

我的实际问题是,我不知道如何用网格做三维图。 Wioth plot3d()我只是一条曲线,对我来说没用。就像回答较旧的问题一样,解决方案应该是这样的:

X = reshape(A(:,1),m,n);
Y = reshape(A(:,2),m,n);    % might be reshape(data(:,2),n,m)
Z = reshape(A(:,3),m,n);
mesh(X,Y,Z);

解释:在这种情况下,假设你在Y中有m个唯一值,在X中有n个唯一值。你可能需要在调用网格中将它们转换为网格(X',Y',Z)或其他东西像那样。

据我所知,解释m和n必须是我3d图中x和y方向的网格点数量。我所遇到的问题是,例如,对应于x方向上的一个网格点的y方向上的网格点可以从点到点改变。

 aa=unique(a)
 bb=unique(b)
 lengthaa=length(aa)
 lengthbb=length(bb)

我得到了我的3d绘图的最终网格尺度(n,m)=((lengthaa),长度(bb)),但是当我想重塑A像我上面写的那样时,我当然会得到如下错误信息:

 octave:20> x = reshape (A(:,1),clength,dlength)
 error: reshape: can't reshape 36x1 array to 6x12 array

而现在我甚至不知道该搜索什么。你能帮忙吗? :)

编辑:现在我更进一步:用

 [aaa,bbb]=meshgrid(aa,bb)

我有正确的斧头。现在我必须以正确的方式订购我的数据。

编辑2:问题是,我现在有网格点,我没有任何数据。这就是原因,为什么重塑不起作用。有帮助吗?

plot 3d octave mesh
1个回答
3
投票

要生成缺失点,您可以插入数据。我做了一个快速测试,因为我遇到了类似的问题:

# Test script for http://stackoverflow.com/questions/19604387/octave-3d-plot-with-mesh-out-of-experimental-data
# Trygve Utstumo, 2013-10-28

data = [
4.00000   7.00000   0.09035
4.00000   6.00000   0.02632
4.00000   5.00000   0.01184
4.00000   4.00000   0.30728
4.00000   3.00000   0.16022
4.00000   2.00000   0.01734
3.00000   6.00000   0.05817
3.00000   5.00000   0.02296
3.00000   4.00000   0.00000
3.00000   3.00000   0.22576
3.00000   2.00000   0.08331
3.00000   1.50000   0.00297
2.00000   6.00000   0.00000
2.00000   5.00000   0.05184
2.00000   4.00000   0.01883
2.00000   3.00000   0.00000
2.00000   2.00000   0.10719
2.00000   1.50000   0.06689
];

# Evenly spaced axis, hacked to this dataset 
xi = min(data(:,1)):max(data(:,1));
yi = min(data(:,2)):0.5:max(data(:,2));

zi = griddata( data(:,1),data(:,2),data(:,3),xi,yi);

mesh( xi, yi, zi )
print("figure.png")
pause()

© www.soinside.com 2019 - 2024. All rights reserved.