1 / 12

数学建模

数学建模. 程 序 设 计. 1. 统计满足条件 x^2+y^2+z^2=2000 的所有解的个数. clc clear M=[]; for x=1:44 for y=1:44 for z=1:44 if x^2+y^2+z^2==2000 M=[M;x,y,z]; end end end end M size(M).

Download Presentation

数学建模

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 数学建模 程 序 设 计

  2. 1.统计满足条件x^2+y^2+z^2=2000的所有解的个数 clc clear M=[]; for x=1:44 for y=1:44 for z=1:44 if x^2+y^2+z^2==2000 M=[M;x,y,z]; end end end end M size(M)

  3. x,y分别表示平面上一个点的坐标,求下列10个点与点(1.0,1.0)的距离的总和。x,y分别表示平面上一个点的坐标,求下列10个点与点(1.0,1.0)的距离的总和。 x={-1.5,2.1,6.3,3.2,-0.7,7.0,5.1,3.2,4.5,7.6}; y={3.5,7.6,8.1,4.5,6.0,1.1,1.2,2.1,3.3,4.4}; clc clear x=[-1.5,2.1,6.3,3.2,-0.7,7.0,5.1,3.2,4.5,7.6]; y=[3.5,7.6,8.1,4.5,6.0,1.1,1.2,2.1,3.3,4.4]; s=0; for i=1:10 s=s+sqrt((x(i)-1)^2+(y(i)-1)^2); end s

  4. 在正整数中找出1个最小的、被3、5、7、9除余数分别为1、3、5、7的数 clc clear for i=1:10000 if mod(i,3)==1 & mod(i,5)==3 & mod(i,7)==5 & mod(i,9)==7 i end end

  5. 计算表达式1+2!+3!+...+12!的值 clc clear s=0; for i=1:12 s=s+prod(1:i); end s

  6. 求斐波那契(Fibonacci)数列中大于t的最小的一个数,其中斐波那契数列F(n)的定义为:求斐波那契(Fibonacci)数列中大于t的最小的一个数,其中斐波那契数列F(n)的定义为: F(0)=0,F(1)=1 F(n)=F(n-1)+F(n-2) 分别计算当t=1000和t=3000时的结果。 clc clear i=1;t=3000; while fibo(i)<=t i=i+1; end fibo(i),i function z=fibo(n) f(1)=0;f(2)=1; for i=3:n f(i)=f(i-1)+f(i-2); end z=f(n);

  7. 利用公式π/4≈1-1/3+1/5-1/7+……公式计算π的近似值,直到某一项的绝对值小于1e-6为止 clc clear i=1;temp=0; while 1/i>1e-6 temp=temp+(-1)^((i-1)/2)*1/i; i=i+2; end pai=4*p

  8. 求解百鸡问题。已知公鸡每只5元、母鸡每只3元、小鸡1元3只。求出用100元买100只鸡的解。 clear clc m=[]; for x=1:20 for y=1:34 for z=1:300 if 5*x+3*y+z/3==100 & x+y+z==100 m=[m; x,y,z]; end end end end m

  9. 在数组a的10个数中求平均值v,将大于等于v的数组元素进行求和。 a={7.23,1.5,5.24,2.1,2.45,6.3,5,3.2,0.7,9.81} a=[7.23,1.5,5.24,2.1,2.45,6.3,5,3.2,0.7,9.81]; v=mean(a); b=0; for i=1:10 if a(i)>=v; b=b+a(i); end end b

  10. 寻找11至999之间的数m,它满足m、m*m、m*m*m均为回文数。所谓回文数是指各位数字左右对称,例如121、676、94249等。满足上述条件的数如m=11,m^2=121,m^3=1331皆为回文数。寻找11至999之间的数m,它满足m、m*m、m*m*m均为回文数。所谓回文数是指各位数字左右对称,例如121、676、94249等。满足上述条件的数如m=11,m^2=121,m^3=1331皆为回文数。 clc clear for i=11:9999 if hw(i)==1 & hw(i^2)==1 & hw(i^3)==1 i end end

  11. function z=hw(n) L=fix(log10(n)+1); nn=0; for i=1:L temp(i)=n-fix(n/10^i)*10^i; end temp2=temp; for i=2:L temp2(i)=(temp(i)-temp(i-1))/10^(i-1); end for i=1:L nn=temp2(L-i+1)*10^(i-1)+nn; end if n==nn z=1; else z=0; end

  12. 数组元素x、y表示平面上某点坐标,统计所有各点间最短距离 x={1.1,3.2,-2.5,5.67,3.42,-4.5,2.54,5.6,0.97,4.65}; y={-6,4.3,4.5,3.67,2.42,2.54,5.6,-0.97,4.65,-3.33}; clc clear x=[1.1,3.2,-2.5,5.67,3.42,-4.5,2.54,5.6,0.97,4.65]; y=[-6,4.3,4.5,3.67,2.42,2.54,5.6,-0.97,4.65,-3.33]; for i=1:10 for j=1:10 if i~=j L(i,j)=sqrt((x(i)-x(j))^2+(y(i)-y(j))^2); else L(i,j)=inf; end end end min(min(L)) L==min(min(L))

More Related