MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   y=1/(x.^2)+5;我想画出这个方程的图线 (https://www.labfans.com/bbs/showthread.php?t=2408)

ryan_ff 2008-04-19 05:38

y=1/(x.^2)+5;我想画出这个方程的图线
 
>> x=-100:0.07:100;

>> y=1/(x.^2)+5;

>>plot(x,y)

我想画出这个方程的图线,但是总是出错。请问怎么修改。就是x不能等于0.

请注意:为了让方程有意义,我设置了步长是 0.07, 所以x不会等于0,反而图线画出来会穿过y轴。


谢谢

未注册 2008-04-19 10:23

x=-100:0.07:100;
y=1./(x.^2)+5;
plot(x,y)
axis([-100 100 0 10])

shiqiang 2008-04-19 18:27

x=-100:1:100;
y=1./[(x.^2)+eps]+5;
plot(x,y)
axis([-100 100 0 10])

shiqiang 2008-04-19 18:28

eps是指一个最小值,为了防止零在分母上出现,加一个极小值就可以。


所有时间均为北京时间。现在的时间是 11:13

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.