一个小程序
<P>a=1;b=3;c=1;d=5;s=2;r=0.001;<BR>z=;y=;x=[-1.6];<BR>I2=[];I1=[];<BR>t=1;<BR>while t<=3<BR>I2(t)=4*0.08*(exp(-(t-1)/3)-exp(-(t-1)/2));<BR>I1(t)=4*(-1)*(exp(-(t-1)/3)-exp(-(t-1)/2)); <BR> z(t+1)=r*(s*(s-x(1))-z(t));<BR> y(t+1)=c-d*x(t)^2-y(t);<BR> x(t+1)=y(t)+a*x(t)^3-b*x(t)^2-z(t)+I1(t)+I2(t);<BR> t=t+1;<BR>end<BR>运行之后<BR>>> x<BR>x =<BR>1.0e+009 *<BR> -0.0000 -0.0000 -0.0000 -8.7706<BR>但是答案不应该是这么多。于是输入<BR>>> x(2)<BR>ans =<BR>-11.7760<BR>但是之前的x显示第二个成员的值为0啊。<BR>这是为什么啊????</P> <P>你要使用format long格式,<BR>俺的结果如下:<BR><BR>To get started, select MATLAB Help or Demos from the Help menu.</P><P>>> a=1;b=3;c=1;d=5;s=2;r=0.001;<BR>z=;y=;x=[-1.6];<BR>I2=[];I1=[];<BR>t=1;<BR>while t<=3<BR>I2(t)=4*0.08*(exp(-(t-1)/3)-exp(-(t-1)/2));<BR>I1(t)=4*(-1)*(exp(-(t-1)/3)-exp(-(t-1)/2)); <BR> z(t+1)=r*(s*(s-x(1))-z(t));<BR> y(t+1)=c-d*x(t)^2-y(t);<BR> x(t+1)=y(t)+a*x(t)^3-b*x(t)^2-z(t)+I1(t)+I2(t);<BR> t=t+1;<BR>end<BR>>> <BR>>> x<BR>x =<BR>1.0e+009 *<BR>-0.00000000160000-0.00000001177600-0.00000206126163-8.77063443897300<BR>>> x(2)<BR>ans =<BR> -11.77600000000000<BR>>> format short<BR>>> x(2)<BR>ans =<BR>-11.7760<BR>>> x<BR>x =<BR>1.0e+009 *<BR> -0.0000 -0.0000 -0.0000 -8.7706<BR>>> <BR>呵呵</P> <P>太感谢了</P>
页:
[1]