当前位置: 首页 > 其他范文 > 其他范文

第3章实验

作者:okok6789 | 发布时间:2021-01-07 12:38:42 收藏本文 下载本文

验 实验 3 matlab 程序设计 陈录平工自 03-1 030544103 3-1>> N=[1:5];>> N1=2*N N1 = 2 4 6 8 10 >> N/2 ans = 0.5000 1.0000 1.5000 2.0000 2.5000 >> 1./N ans = 1.0000 0.5000 0.3333 0.2500 0.2000 >> 1./(N.*N)ans = 1.0000 0.2500 0.1111 0.0625 0.0400 3-2>> n=input("n=");a1=fix(n/100);a2=rem(fix(n/10),10);a3=rem(n,10);m=a1+a2*10+a3*100;n=214 >> m m = 412 3-3(1)m=input("m=");switch fix(m/10)case{9,10} c="A";case{8} c="B";case{7} c="C";

case{6} c="D";case{0:5} c="E";otherwise c="error";end;m=566 >> c c = error(2)m=input("m=");if m<=100&m>=90 c="A";elseif m<90&m>=80 c="B";elseif m<80&m>=70 c="C";elseif m<70&m>=60 c="D";elseif m<60&m>=0 c="E";else c="error";end;c m=78 c = C 3-4 M=12+(82-12)*randn(5,6);n=input("n=");if n>=1&n<=5 N=M(n,:);else N=M(5,:);end;N n=6 N =-43.7578 72.9234-151.3973 89.8930-81.3055-85.1371 3-5,X=zeros(1,20);sum=0;for i=1:20

X(i)=fix(100*rand);sum=sum+X(i);end mean=sum/20;disp(mean);for i=1:20 if X(i)

-1.8971-1.5978-1.3575-1.1531-0.9723 Columns 36 through 40-0.8083-0.6567-0.5151-0.3819-0.2561 Columns 41 through 45-0.1374-0.0255 0.0792 0.1766 0.2663 Columns 46 through 50 0.3478 0.4206 0.4841 0.5379 0.5815 Columns 51 through 55 0.6145 0.6366 0.6474 0.6470 0.6351 Columns 56 through 60 0.6119 0.5777 0.5327 0.4774 0.4126 Column 61 0.3388(2)clear;a=-3.0:0.1:3.0;y=(exp(0.3.*a)-exp((-0.3).*a))/2.*sin(a+0.3)+log((0.3+a)./2)y = Columns 1 through 5 0.7388 + 3.1416i 0.7696 + 3.1416i 0.7871 + 3.1416i 0.7913 + 3.1416i 0.7822 + 3.1416i Columns 6 through 10 0.7602 + 3.1416i 0.7254 + 3.1416i 0.6784 + 3.1416i 0.6196 + 3.1416i 0.5496 + 3.1416i Columns 11 through 15 0.4688 + 3.1416i 0.3780 + 3.1416i 0.2775 + 3.1416i 0.1680 + 3.1416i 0.0497 + 3.1416i Columns 16 through 20-0.0771 + 3.1416i-0.2124 + 3.1416i-0.3566 + 3.1416i-0.5104 + 3.1416i-0.6752 + 3.1416i Columns 21 through 25-0.8536 + 3.1416i-1.0497 + 3.1416i-1.2701 + 3.1416i-1.5271 + 3.1416i-1.8436 + 3.1416i Columns 26 through 30-2.2727 + 3.1416i-2.9837 + 3.1416i-37.0245-3.0017-2.3085 Columns 31 through 35-1.8971-1.5978-1.3575-1.1531

-0.9723 Columns 36 through 40-0.8083-0.6567-0.5151-0.3819-0.2561 Columns 41 through 45-0.1374-0.0255 0.0792 0.1766 0.2663 Columns 46 through 50 0.3478 0.4206 0.4841 0.5379 0.5815 Columns 51 through 55 0.6145 0.6366 0.6474 0.6470 0.6351 Columns 56 through 60 0.6119 0.5777 0.5327 0.4774 0.4126 Column 61 0.3388 3-8,(1)clear;n=[100,1000,10000];sum=zeros(1,3);for j=1:3 for i=1:n(j)y=1/i^2;sum(j)=sum(j)+y;end end disp(sum)答案 1.6350 1.6439 1.6448 向量 clear;n=input("请输入 100,1000,10000:");i=1:n;y=sum((1./i).^2);disp(y)答案请输入 100,1000,10000:100 1.6350 请输入 100,1000,10000:1000 1.6439 请输入 100,1000,10000:10000 1.6448 3-8(2), 向量 clear;n=input("请输入 100,1000,10000:");i=1:4:2*n-3;

j=3:4:2*n-1;y=sum(1./i)-sum(1./j);disp(y)请输入 100,1000,10000:1000 y =0.7853 请输入 100,1000,10000:100 0.7829 请输入 100,1000,10000:1000 0.7851 请输入 100,1000,10000:10000 0.7854 循环 clear;n=[100,1000,10000];sum=zeros(1,3);for j=1:3 for i=1:n(j)y=1/((-1)^(i+1)*(2*i-1));sum(j)=sum(j)+y;end end disp(sum)答案 0.7829 0.7851 0.7854 3-8(3)clear;n=[100,1000,10000];sum=zeros(1,3);for j=1:3 for i=1:n(j)y=1/(4^i);sum(j)=sum(j)+y;end end disp(sum)答案 0.3333 0.3333 0.3333 向量 3-8(4)clear;n=[100,1000,10000];sum=[1,1,1];for j=1:3 for i=1:n(j)y=((2*i)^2)/((2*i-1)*(2*i+1));sum(j)=sum(j)*y;end end

disp(sum)答案 1.5669 1.5704 1.5708 3-9,(1)n=0;for i=2:49 x=i*(i+1)-1;for j=2:sqrt(x)if rem(x,j)==0;x=0;end end if x~=0 n=n+1 end end disp(n)答案 28(2)sum=0;for i=2:49 x=i*(i+1)-1;for j=2:sqrt(x)if rem(x,j)==0;x=0;end end sum=sum+x;end disp(sum)答案 21066 3-10,(1)a=1;y=0;while(y<3)i=1:2:2*a-1;y=sum(1./i);a=a+1;end n=a-2;disp(n)答案 56 i=1:2:111;y=sum(1./i)答案 2.9944 3-11(1)n=40;f1=n+10*log(n*n+5);

m=30;f2=m+10*log(m*m+5);o=20;f3=o+10*log(o*o+5);y=f1./(f3+f3)y = 0.7110(2)n=40;f1=0;for i=1:n f1=f1+i*(i+1);end n=30;f2=0;for j=1:n f2=f1+j*(j+1);end n=20;f3=3;for k=1:n f3=f3+k*(k+1);end y=f1/(f2+f3)y = 0.8512 3-12 function [c]=cheng(a,b)try c=a*b;catch c=a.*b;end c lasterr [c]=cheng([1,2,3;3,2,1],[1,2;3,2;5,6])c = 22 24 14 16 ans =

Error using ==> unknown Matrix dimensions must agree.3-13 function [a,b,c,d]=qiu(e)a=exp(e);b=log(e);c=sin(e);d=cos(e);[a,b,c,d]=qiu(1+i)a = 1.4687 + 2.2874i b = 0.3466 + 0.7854i c = 1.2985 + 0.6350i d = 0.8337-0.9889i 3-14 function f=factor(n)if n<=1 f=1;else f=factor(n-1)+n;end s=factor(100)+factor(50).*factor(50)+1./factor(10)s = 1.6307e+006 3-15(1)108(2)x = 4 12 20 y = 2 4 6

数据结构实验

流体力学实验

实验操作

实验记录本

实验设备

本文标题: 第3章实验
链接地址:https://www.dawendou.com/fanwen/qitafanwen/364648.html

版权声明:
1.大文斗范文网的资料来自互联网以及用户的投稿,用于非商业性学习目的免费阅览。
2.《第3章实验》一文的著作权归原作者所有,仅供学习参考,转载或引用时请保留版权信息。
3.如果本网所转载内容不慎侵犯了您的权益,请联系我们,我们将会及时删除。

重点推荐栏目

关于大文斗范文网 | 在线投稿 | 网站声明 | 联系我们 | 网站帮助 | 投诉与建议 | 人才招聘 | 网站大事记
Copyright © 2004-2025 dawendou.com Inc. All Rights Reserved.大文斗范文网 版权所有