在 matlab 中绘制给定方程的 3D 平面 [英] Plot 3D plane given equations in matlab

查看:53
本文介绍了在 matlab 中绘制给定方程的 3D 平面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为下面给出的方程绘制 2 个 3D 平面:

I want to plot 2 3D planes for the equations given below :

x + y + z = 1
2x - y = 0

对于第一个方程,我使用 meshgrid 将其绘制为:

For 1st equation, I plotted it using meshgrid as :

[x y] = meshgrid(-5:0.5:5);  
z = 1 - x - y  
mesh(x,y,z)

但是对于第二个方程,没有给出 z,即 z 可以是任何东西,那么我该如何绘制平面呢?

But for 2nd equation, z is not given i.e. z can be anything, then how do I plot plane for this ?

推荐答案

评论正确.这更像是一道数学题.您绘制一条线 2x - y = 0 并将其转换为任何 z 值以创建一个平面.

The comments are correct. It is more of a math problem. You draw a line 2x - y = 0 and translate it for any z value to create a plane.

[x, y] = meshgrid(-5:0.5:5);  
Zv = @(x,y) 1 - x - y;
mesh(x,y,Zv(x,y));

hold on

[x, z] = meshgrid(-5:0.5:5);
Yv = @(x) 2*x;
mesh(x,Yv(x),z);

hold off

这篇关于在 matlab 中绘制给定方程的 3D 平面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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