在Matlab中以一般形式绘制二次曲面 [英] plot Quadric Surfaces in General Form in matlab

查看:361
本文介绍了在Matlab中以一般形式绘制二次曲面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有二次曲面方程

我知道A,B,C ... 如何在Matlab中绘制方程式?

I know A,B,C... How can I plot my equation in matlab?

推荐答案

您最好的选择是生成一个函数的3D等高线图,其中单个等高线的值为0.要做到这一点,请计算您的函数的精度在点x,y,z处的F如下:

Your best bet is to produce a 3D contour plot of your function with a single contour at the function value 0. To do this with reasonable accuracy, compute your function F at a number of points x, y, z as follows:

gv = linspace(-30,30,50); % adjust for appropriate domain
[xx yy zz]=meshgrid(gv, gv, gv);
F = A*xx.*xx + B*yy.*yy + C*zz.*zz+ ... etc

figure
isosurface(xx, yy, zz, F, 0)

之所以这样做,是因为您的函数通常是多值的-也就是说,对于给定的X和Y值,Z可能有两个答案.通过这种方式,您可以有效地绕过该问题-指示matlab将曲面放置在函数为零的任何地方.

The reason to do it this way is that your function is typically multi-valued- that is, for a given value of X and Y there may be two possible answers for Z. By doing things this way you effectively bypass that problem - instructing matlab to put a surface anywhere that the function is zero.

请注意,我为网格提供了任意向量gv-即计算函数的点.为了获得准确的视觉效果,在可能的解决方案范围内,每个维度可能需要大约50个点(这在三个维度上可能有所不同);

Note that I gave an arbitrary vector gv for the grid - that is, the points on which the function is evaluated. To get an accurate and visually pleasing result you probably need around 50 points in each dimension within the range over which a solution is possible (this may be different in the three dimensions);

例如,使用

F = xx.^2 + 2*yy.^2 + 0.5*zz.^2 + .4*xx.*yy + .5*xx.*zz + .6*yy.*zz + 7*xx + 8*yy + 9*zz - 100;

您将看到下图:

这篇关于在Matlab中以一般形式绘制二次曲面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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