1

我有一个问题,也许你能帮助我。就像在标题中一样,我有对称镜头的横截面数据 - 坐标s=-100:1:100和高度y- 我想创建整个镜头的 3D 绘图(x,y,z)。是否有任何内置功能对此有所帮助?提前感谢您的帮助!

4

2 回答 2

0

如果没有更多规格(例如,如果您y是 2D 矩阵或 1D 数组),就不可能给您确切的答案。然而,这是您在 Matlab 中绘制曲面的方式:

% create a meshgrid used as the independent variables of your surface
[sx, sy] = meshgrid(-100:100); 
% if you have your own 2D matrix, ignore this line. 
% if you have a formula, replace this line with your own formula
y = cos(sqrt(((sx/100).^2+(sy/100).^2)/2)*(pi/2));
% draw the surface
surf(sx, sy, y);

为了也有相反的一面,在同一个图形上画另一个冲浪:

hold on;
surf(sx, sy, -y);
于 2013-05-22T13:16:53.677 回答
0

如果我理解正确,您有一个 1-D 数组,您希望有效地围绕一个圆圈“扫描”以生成 3-D 图。这是一个如何做到这一点的例子

% Some dummy data
Npts = 100;
z = sin(linspace(0, pi, Npts));

Nreps = 100; % How many times to repeat around circle
% Create polar meshgrid and convert to Cartesian
[r, theta] = meshgrid( ...
    linspace(-length(z)/2, length(z)/2, Npts), ...
    linspace(0, pi, Nreps));
[X, Y] = pol2cart(theta, r);
% Copy data Nreps times
Z = repmat(z, Nreps, 1);

% Plot!
surf(X, Y, Z)
于 2013-05-22T13:36:00.730 回答