通过拟合具有不同z值的许多2D图来生成3D表面图 [英] Generate a 3D surface plot by fitting over many 2D plots with varying z value

查看:111
本文介绍了通过拟合具有不同z值的许多2D图来生成3D表面图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得3D表面图.我的输出如下.

I would like to achieve a 3D surface plot. My outputs are as follows.

对于z的特定值,对于每个x值(x范围如0:0.1:1.4),我都得到y.

For a particular value of z, I get y for each value of x (x ranges like 0:0.1:1.4).

然后我改变z,对于相同范围的x,我得到y值.

Then I vary z and, for the same range of x, I get y values.

结果可以显示为离散的z值的2D图,其中包括x的范围及其对应的y.这是我的原始情节:

The result can be visualised as 2D plots at discrete z values, consisting of the range of x and its corresponding y. Here is my original plot:

我想创建一个3D表面图,就像上面2D图上包裹的毯子一样.

I would like to create a 3D surface plot instead, like a blanket wrapped over the above 2D plots.

推荐答案

以下是两种绘图的示例:

Here's an example for the two types of plots:

figure
hold on
grid on
view(30,40)
x = 0:.01:4;
z = .3:.3:3;
y = NaN(numel(x), numel(z));
for k = 1:numel(z)
    y(:,k) = abs((4-x).*sin(x/(1+z(k)))); % compute a vector as function output
        % for input vector x, for each z. Store as a column in matrix y
    plot3(x,repmat(z(k),size(x)),y(:,k)) % plot in 3D space
end

figure
surf(x,z,y.','edgecolor','none') % surface plot
view(30,40)
grid on

这篇关于通过拟合具有不同z值的许多2D图来生成3D表面图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆