【问题标题】:How I can draw the graph of three equations (x=x(u,v,w), y=y(u,v,w), z=z(u,v,w)) involving three parameters using Matlab?如何使用 Matlab 绘制涉及三个参数的三个方程 (x=x(u,v,w), y=y(u,v,w), z=z(u,v,w)) 的图形?
【发布时间】:2019-04-18 16:27:26
【问题描述】:

我得到了三个涉及三个参数的方程 x=u*cos(2*pi*v), y=u*sin(2*pi*v), z=sqrt(1-u^2)*(2*w-1), 其中uvw 属于[0,1]

如何使用 matlab 绘制上述方程的图形? 我已经尝试了三个嵌套的 for 循环,但这真的很花时间。以这种方式获得的图形由点组成,其质量不太好。

有没有其他方法可以在Matlab中绘制这些方程的图形?

【问题讨论】:

标签: matlab-figure


【解决方案1】:

您不需要循环来创建计算矩阵。下面是创建矩阵和绘图的示例。它可能不是您正在寻找的东西,但它应该能让您接近。

% set up values to calc for for u,v,w in [0,1]
stepsize = 0.1;
u = 0:stepsize:1; % min, step, max
v = 0:stepsize:1;
w = 0:stepsize:1;

% now set up combined tables
u = u';
v = v';
w = w';

uv = [repmat(u, length(v),1), repmat(v, length(u),1)];
uw = [repmat(u, length(w),1), repmat(w, length(u),1)];


% now do calcs
% note u-vector is uv(:,1) or uw(:,1), depending upon the combo, etc.
x = uv(:,1) .* cos(2 * pi * uv(:,2));
y = uv(:,1) .* sin(2 * pi * uv(:,2));
z = sqrt(1 - uw(:,1) .^2) .* (2 * uw(:,2) -1);

% it's not clear what you want to plot, but here are some examples
figure
hold on
subplot(4,1,1)
plot(x, y, 'Color', 'green', 'DisplayName', 'XY');
box on
title('Your Title Here', 'FontSize', 10)
xlabel('X', 'FontSize', 8)
ylabel('Y', 'FontSize', 8)
set(legend, 'Location', 'best')

subplot(4,1,2)
plot(x, z, 'Color', 'blue', 'DisplayName', 'XZ');
box on
title('Your Title Here', 'FontSize', 10)
xlabel('X', 'FontSize', 8)
ylabel('Z', 'FontSize', 8)
set(legend, 'Location', 'best')

subplot(4,1,3)
plot(y, z, 'Color', 'red', 'DisplayName', 'YZ');
box on
title('Your Title Here', 'FontSize', 10)
xlabel('Y', 'FontSize', 8)
ylabel('Z', 'FontSize', 8)
set(legend, 'Location', 'best')

subplot(4,1,4)
plot3(x, y, z, 'Color', 'magenta', 'DisplayName', 'XYZ');
box on
grid on
ax = gca;
ax.GridAlpha = 0.5;
title('Your Title Here', 'FontSize', 10)
xlabel('X', 'FontSize', 8)
ylabel('Y', 'FontSize', 8)
zlabel('Y', 'FontSize', 8)
set(legend, 'Location', 'best')

上面产生了这个数字:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 2013-02-26
    • 2021-04-25
    • 2014-08-26
    相关资源
    最近更新 更多