解不等式的图解法

这个例子展示了一个有趣的图形化的方法来找出e^pi是否大于pi^e。

东西/原料

  • matlab软件
  • 电脑

方式/步调

  1. 1

    号令行键入:

    % Define the mesh

    x = 0:0.16:5;

    y = 0:0.16:5;

    [xx,yy] = meshgrid(x,y);


    % The plot

    zz = xx.^yy-yy.^xx;

    h = surf(x,y,zz);


    % Set the properties of the plot

    h.EdgeColor = [0.7 0.7 0.7];

    view(20,50);

    colormap(hsv);

    title('z = x^y-y^x');

    xlabel('x');

    ylabel('y');

    hold on;

  2. 2

    按“Enter”键。

    如图1所示。

  3. 3

    号令行键入:

    c = contourc(x,y,zz,[0 0]);

    list1Len = c(2,1);

    xContour = [c(1,2:1+list1Len) NaN c(1,3+list1Len:size(c,2))];

    yContour = [c(2,2:1+list1Len) NaN c(2,3+list1Len:size(c,2))];

    % Note that the NAN above prevents the end of the first contour line from being

    % connected to the beginning of the second line

    line(xContour,yContour,'Color','k');

  4. 4

    按“Enter”键。

    如图2所示。

  5. 5

    号令行键入:

    plot([0:5 2 4],[0:5 4 2],'r.','MarkerSize',25);

  6. 6

    按“Enter”键。

    如图3所示。

  7. 7

    号令行键入:

    e = exp(1);

    plot([e pi],[pi e],'r.','MarkerSize',25);

    plot([e pi],[pi e],'y.','MarkerSize',10);

    text(e,3.3,'(e,pi)','Color','k', ...

       'HorizontalAlignment','left','VerticalAlignment','bottom');

    text(3.3,e,'(pi,e)','Color','k','HorizontalAlignment','left',...

       'VerticalAlignment','bottom');

    hold off;

  8. 8

    按“Enter”键。

    如图4所示。

  9. 9

    号令行键入:

    e = exp(1);

    e^pi

    pi^e

  10. 10

    按“Enter”键。

    如图5所示。

    END
原作者:matlab教程举报
  • 发表于 2020-02-13 20:00
  • 阅读 ( 1401 )
  • 分类:其他类型

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
联系我们:uytrv@hotmail.com 问答工具