繁体   English   中英

MATLAB 3D曲线图

[英]MATLAB 3D Plotting of Curves

我要尝试绘制2个变量,但无法弄清楚要使用哪些函数才能获得所需的图形。 例如,我有一个变量Depth,它是一个充满数字的70x12矩阵。 每年的每个月12个。 我正在尝试针对温度绘制深度,这也是一个70x12的数字矩阵。 我目前这样做的方法是在for循环中使用plot3并保持不变,并在z轴上绘制每个以1分隔的深度与温度曲线。 看起来像这样:

当旋转时,它看起来像这样:

但是,我想要的是曲线之间的某种网格或冲浪,以便图形看起来与此相似。 我在网上冲浪并进行了不错的划分,但我不知道如何使用存储在变量中的数据来绘制曲线和通过曲面的曲面,看起来像这样。

在此处输入图片说明

您可以使用plot3surf进行plot3 ,但是强烈建议使用plot3创建深度,温度和月份的矩阵。

以下代码显示了如何执行此操作。 我只是做了一些所谓的任意温度数据temps ,然后用meshgrid把深度和个月的载体导入对应于临时工每个条目的网格。 请注意,由于MD现在是矩阵,所以不需要for循环,只需一次plot3所有3矩阵即可。

% create some data. The problem is that depths and months are vectors while
% I have a 70x12 grid o temperatures:
nd = 70;
depths = linspace(0, 1e3, nd);
months = 1:12;
temps = sin((1:nd)'*months/(nd*8));


% So make temps and depths matrices too:
[M, D] = meshgrid(months, depths)

% and now plot:
figure(112)
clf

% plot the surface from the matrices returned by meshgrid: notice I used
% facealpha to change the transparency:
hs = surf(temps, D, M, 'facealpha', .5);
hold all;

% now that we used meshgrid we can plot everything at once:
plot3(temps, D, M, 'linewidth', 3)

view(3)
grid on

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM