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

查看:398
本文介绍了在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天全站免登陆