资源描述:
《数学实验解答》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第一章%Page20,ex1(5)等于[exp(1),exp(2);exp(3),exp(4)](7)3=1*3,8=2*4(8)a为各列最小值,b为最小值所在的行号(10)1>=4,false,2>=3,false,3>=2,ture,4>=1,ture(11)答案表明:编址第2元素满足不等式(30>=20)和编址第4元素满足不等式(40>=10)(12)答案表明:编址第2行第1列元素满足不等式(30>=20)和编址第2行第2列元素满足不等式(40>=10)%Page20,ex2(1)a,b,c的值尽管都是1,但
2、数据类型分别为数值,字符,逻辑,注意a与c相等,但他们不等于b(2)double(fun)输出的分别是字符a,b,s,(,x,)的ASCII码%Page20,ex3>>r=2;p=0.5;n=12;>>T=log(r)/n/log(1+0.01*p)T=11.5813%Page20,ex4>>x=-2:0.05:2;f=x.^4-2.^x;>>[fmin,min_index]=min(f)fmin=-1.3907%最小值min_index=54%最小值点编址>>x(min_index)ans=0.6500%最小值点
3、>>[f1,x1_index]=min(abs(f))%求近似根--绝对值最小的点f1=0.0328x1_index=24>>x(x1_index)ans=-0.8500>>x(x1_index)=[];f=x.^4-2.^x;%删去绝对值最小的点以求函数绝对值次小的点>>[f2,x2_index]=min(abs(f))%求另一近似根--函数绝对值次小的点f2=0.0630x2_index=65>>x(x2_index)ans=1.2500%Page20,ex5>>z=magic(10)z=92991815677
4、4515840988071416735557644148188202254566370478587192136062697128869325296168755234172476839042492633652358289914830323966796139597293138457210129496783537444653111810077843643502759>>sum(z)ans=505505505505505505505505505505>>sum(diag(z))ans=505>>z(:,2)/sqrt(3)
5、ans=57.157746.188046.765450.229553.693613.85642.88683.46416.928210.3923>>z(8,:)=z(8,:)+z(3,:)z=929918156774515840988071416735557644148188202254566370478587192136062697128869325296168755234172476839042492633652358289914830323966838710111511983871011151191012949
6、6783537444653111810077843643502759第二章%Page40ex1先在编辑器窗口写下列M函数,保存为eg2_1.mfunction[xbar,s]=ex2_1(x)n=length(x);xbar=sum(x)/n;s=sqrt((sum(x.^2)-n*xbar^2)/(n-1));例如>>x=[81706551766690876177];>>[xbar,s]=ex2_1(x)xbar=72.4000s=12.1124%Page40ex2s=log(1);n=0;whiles<=100
7、n=n+1;s=s+log(1+n);endm=n计算结果m=37%Page40ex3clear;F(1)=1;F(2)=1;k=2;x=0;e=1e-8;a=(1+sqrt(5))/2;whileabs(x-a)>ek=k+1;F(k)=F(k-1)+F(k-2);x=F(k)/F(k-1);enda,x,k计算至k=21可满足精度%Page40ex4clear;tic;s=0;fori=1:1000000s=s+sqrt(3)/2^i;ends,toctic;s=0;i=1;whilei<=1000000s=s
8、+sqrt(3)/2^i;i=i+1;ends,toctic;s=0;i=1:1000000;s=sqrt(3)*sum(1./2.^i);s,toc%Page40ex5t=0:24;c=[15141414141516182022232528...313231292725242220181716];plot(t,c)%Page40ex6%(1)x=-2:0.