本文介绍了如何在 scilab 中绘制心脏曲线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在论坛和程序帮助的图形功能中寻找如何绘制以下功能的图形:

I have been looking in the forum and within the graphical functions of the program help, how to graph the following function:

x2=[-2:0.02:2]';x1=[-1:0.01:1]';
function val = Heart(x1, x2)
    val=(1.2*x2-sqrt(abs(x1)))^2+x1^2-1;
endfunction

而且我还没有找到任何可以指导我的东西.我尝试重现这个枫树图:心形曲线

And I have not found anything to guide me.I try to reproduce this maple plot:Heart curve

推荐答案

既然你定义了一个 3D 表面,你就可以使用 contourcontour2d:正如 luispauloml,可以直接将函数作为参数传递.>

Since your defining a 3D surface, you can use contour and contour2d: as said by luispauloml, you can pass the function directly as a parameter.

x1=[-1:0.01:1]
x2=[-2:0.02:2]
function val = Heart(x1, x2)
    val=(1.2*x2-sqrt(abs(x1))).^2+x1.^2-1; // switched ^ to .^ to handle vectors
endfunction;

figure()
xlabel('x1')
ylabel('x2')

contour2d(x1,x2,Heart,[0 0]);

a=gca()
hline=a.children.children(1)
hline.foreground=color('red')
hline.thickness=2

这篇关于如何在 scilab 中绘制心脏曲线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 15:13