



版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、-MATLAB第二版課后答案unit3-8unit3實驗指導'); 請輸入一個三位數:1、 n=input('a=fix(n/100);b=fix(n-a*100)/10);c=n-a*100-b*10;d=c*100+b*10+a輸入成績 n=input('switch ncase num2cell(90:100)case num2cell(80:89))2(1p='A'p='B'');請case num2cell(70:79)p='C'case num2cell(60:69)p='D'other
2、wisep='E'endprice=p請輸入成績)( 2 n=input(''); if n>=90&n<=100elseif n>=80&n<=89p='A'p='B'elseif n>=70&n<=79p='C'elseif n>=60&n<=69p='D'elsep='E'endprice=p) 3(n;try-catchprice='erroe' 3endn=1,5,56,4,3,
3、476,45,6,3,76,45,6,4,3,6,4,23,76,908,6;-a=n(1);b=n(1);for m=2:20if n(m)>aa=n(m);elseif n(m)<bb=n(m);endendmax=amin=b法 2n=1,5,56,4,3,476,45,6,3,76,45,6,4,3,6,4,23,76,908,6;min=min(n)max=max(n)4b=-3.0:0.1:3.0;for n=1:61a=b(n);y(n)=(exp(0.3*a)-exp(-0.3*a)/2*sin(a+0.3)+log(0.3+a)/2);endy5y1=0;y2=1
4、;n=input('請輸入n 的值:');for i=1:ny1=y1+1/i2;y2=y2*(4*i*i)/(2*i-1)*(2*i+1);y1y26endA=1,1,1,1,1,1;2,2,2,2,2,2;3,3,3,3,3,3;4,4,4,4,4,4;5,5,5,5,5,5;6,6,6,6,6,6;n=input('請輸入n 的值:');if n<=5&n>=0disp(A(n,:);-elseif n<0disp(lasterr);else disp(A(6,:);disp(lasterr);end7 (1)f=;-for n=
5、1:40f(n)=n+10*log(n2+5);endy=f(40)/(f(30)+f(20)( 2)f=;a=0;for n=1:40f(n)=a+n*(n+1);a=f(n);endy=f(40)/(f(30)+f(20)8y=0;:');輸入m的值 m=input('');值:輸入 n=input('n for i=1:ny=y+im;end y*function s=shi8_1(n,m) s=0; for i=1:ns=s+im;end*shi8_1(100,1)+shi8_1(50,2)+shi8_1(10,1/2)思考練習2N=1,2,3,4,5;
6、2.*NN./21./N1./N.23s=fix(100*rand(1,20)*9/10+10)y=sum(s)/20-j=0;for i=1:20if s(i)<y&rem(s(i),2)=0j=j+1;A(j)=s(i);else continue;end-endA4y1=0;y2=0;n=input('請輸入n 的值:');for i=1:ny1=y1+-(-1)i/(2*i-1);y2=y2+1/4i;endy1y2unit4實驗指導( 1 1 )x=-10:0.05:10;y=x-x.3./6;plot(x,y)(2) x=-10:0.5:10;ezpl
7、ot('x2+2*y2-64',-8,8);grid on;2t=-pi:pi/10:pi;y=1./(1+exp(-t);subplot(2,2,1);bar(t,y);(t,y)'); title('條形圖axis(-pi,pi,0,1);subplot(2,2,2);stairs(t,y,'b');(t,y)');階梯圖axis(-pi,pi,0,1);subplot(2,2,3);stem(t,y,'k');(t,y)'); title('桿圖axis(-pi,pi,0,1);subplot(2,2
8、,4);loglog(t,y,'y');(t,y)'); title('對數坐標圖title('-3( 1)t=0:pi/50:2*pi;r=5.*cos(t)+4;polar(t,r);title('rho=5*costheta+4');( 2 )-t=-pi/3:pi/50:pi/3;r=5.*(sin(t).2)./cos(t);polar(t,r);4 ( 1 )t=0:pi/50:2*pi;x=exp(-t./20).*cos(t);y=exp(-t./20).*sin(t);z=t;plot3(x,y,z);grid on;(
9、 2 )x,y=meshgrid(-5:5);z=zeros(11)+5;mesh(x,y,z);shading interp;5x,y,z=sphere(20);surf(x,y,z);axis off;shading interp;m=moviein(20);for i=1:20axis(-i,i,-i,i,-i,i)m(:,i)=getframe;end movie(m,4); 思考練習 y=(1./(2*pi).*exp(-(x.2)/2);)( 2 1 x=-5:0.1:5;plot(x,y);(2 )t=-2*pi:0.1:2*pi;x=t.*sin(t);y=t.*cos(t);
10、plot(x,y);grid on;3-t=0:pi/1000:pi;x=sin(3.*t).*cos(t);y1=sin(3.*t).*sin(t);y2=2.*x-0.5;plot(x,y1,'k',x,y2);hold on;-k=find(abs(y1-y2)<1e-2);x1=x(k);y3=2.*x1-0.5;plot(x1,y3,'rp');4x=-2:0.01:2;y=sin(1./x);subplot(2,1,1);plot(x,y);subplot(2,1,2);fplot('sin(1./x)',-2,2,1e-4);
11、5 ( 1 )i=-4*pi:0.1:10;j=12./sqrt(i);polar(i,j);title('rho=12/sqrt(theta)')( 2 )a=-pi/6:0.01:pi/6;b=3.*asin(a).*cos(a)./(sin(a).3+(cos(a).3);polar(a,b);6 ( 1 )u,v=meshgrid(-4:0.1:4);z=4.*u.2;subplot(2,1,1);mesh(x,y,z);subplot(2,1,2);surf(x,y,z);( 2 )x,y=meshgrid(-3:0.2:3);z=-5./(1+x.2+y.2);su
12、bplot(1,2,1);mesh(x,y,z);subplot(1,2,2);surf(x,y,z);unit5實驗指導-1A=randn(10,5)x=mean(A)y=std(A)Max=max(max(A)Min=min(min(A)-Sumhang=sum(A,2)SumA=sum(Sumhang)B=sort(A);C=sort(B,2,'descend');C2 ( 1 ) a=0:15:90;b=a./180.*pi;s=sin(b)c=0:15:75;d=c./180.*pi;t=tan(d)');e=input('請輸入想計算的值:S=sin
13、(e/180*pi)T=tan(e/180*pi)S1=interp1(a,s,e,'spline')T1=interp1(c,t,e,'spline')P1=polyfit(a,s,5);P2=polyfit(c,t,5);S2=polyval(P1,e)T2=polyval(P2,e)) ( 2n=1,9,16,25,36,49,64,81,100;N=sqrt(n);x=input('ji suan zhi : ');interp1(n,N,x,'cubic')3N=64;T=5;t=linspace(0,T,N); h=e
14、xp(-t); dt=t(2)-t(1); f=1/dt; X=fft(t);F=X(1:N/2+1);f=f*(0:N/2)/N;-plot(f,abs(F),'-*')4P=2,-3,0,5,13;Q=1,5,8;p=polyder(P)q=polyder(P,Q)a,b=polyder(P ,Q)-5P1=1,2,4,0,5;P2=0,1,2;P3=1,2,3;P=P1+conv(P2,P3)X=roots(P)A=-1,1.2,-1.4;0.75,2,3.5;0,5,2.5;p=polyval(P ,A)思考練習4A=rand(1,30000);a=mean(A)b=s
15、td(A)Max=max(A)Min=min(A)n=0;for i=1:30000if(A(i)>0.5)n=n+1;endendny=n/300005p=45,74,54,55,14;78,98,45,74,12;87,98,85,52,65M,S=max(p)N,H=min(p)junzhi=mean(p,1)fangcha=std(p,1,1)zong=sum(p,2);Max,wei=max(zong)Min,wei=min(zong)zcj,xsxh=sort(zong,'descend') 6 x=1:10:101;y=0,1.0414,1.3222,1.4
16、914,1.6128,1.7076,1.7853,1.8513,1.9085,1.9590,2.0043;p,s=polyfit(x,y,5)-a=1:5:101;y1=polyval(p,a);plot(x,y,':o',a,y1,'-*')unit6實驗指導1A=1/2,1/3,1/4;1/3,1/4,1/5;1/4,1/5,1/6;-p=0.95,0.67,0.52'x=ApA=1/2,1/3,1/4;1/3,1/4,1/5;1/4,1/5,1/6;p=0.95,0.67,0.53'x=Apcond(A)2 ( 1 )x1=fzero(fu
17、nx1,-1)function fx=funx1(x)fx=x41+x3+1;( 2 )x2=fzero(funx2,0.5)function fx=funx2(x)fx=x-sin(x)/x;( 3 )options=optimset('Display','off');x=fsolve(fun3,1,1,1',options)q=fun3(x)function q=fun3(p)x=p(1);y=p(2);q(1)=sin(x)+y2+log(z)-7;q(2)=3*x+2y-z3+1;q(3)=x+y+z-5;3( 1 )z=p(3); t0=0;t
18、f=5;y0=1;t,y=ode23(fun4,t0,tf,y0);t'y'function yp=fun4(t,y) yp=-(1.2+sin(10*t)*y;( 2 )t0=0;-tf=5;y0=1;t,y=ode23(fun5,t0,tf,y0);t'y'function yp=fun5(t,y)-yp=cos(t)-y/(1+t2);4x=fminbnd(mymin,0,2);-mymin(x)function fx=mymin(x)fx=-(1+x.2)/(1+x.4);5options=optimset('Display','
19、off');x,fval=fmincon(fun6,0,0,0,a,b,lb,ub)-fvalfunction f=fun6(x)f=-(sqrt(x(1)+(400-x(1)*1.1+(sqrt(x(2)+(400-x(1)*1.1 -x(2)*1.1+sqrt(3)+(400-x(1)*1.1-x(2)*1.1-x(3)*1.1+sqrt(x(x4);思考練習1( 1)A=2,3,5;3,7,4;1,-7,1;B=10,3,5'C1=inv(A)*BC2=ABL,U=lu(A);x=U(LB)( 2)A=6,5,-2,5;9,-1,4,-1;3,4,2,-2;3,-9,0,
20、2;B=-4,13,1,11'C1=inv(A)*BC2=ABL,U=lu(A);x=U(LB)2( 1 )x1=fzero(funx1,1.5)function fx=funx1(x)fx=3*x+sin(x)-exp(x);( 2)x1=fzero(funx2,1)function fx=funx2(x)fx=x-1/x+5;( 3 )-options=optimset('Display','off');x=fsolve(fun3,3,0',options)q=fun3(x)function q=fun3(p)x=p(1);-y=p(2);q
21、(1)=x2+y2-9;q(2)=x+y-1;3 ( 1 )t0=0;tf=5;y0=0,1;t,y=ode45(vdpol,t0,tf,y0);t,yfunction ydot=vdpol(t,y);ydot(1)=(2-3*y(2)-2*t*y(1)./(1+t2);ydot(2)=y(1);ydot=ydot'( 2 )t0=0;tf=5;y0=1;0;2;t,y=ode45(vdpoll,t0,tf,y0);t,yfunction ydot=vdpoll(t,y);ydot(1)=cos(t)-y(3)./(3+sin(t)+5*y(1).*cos(2*t)/(t+1). 2)
22、-y(2); ydot(2)=y(1);ydot(3)=y(2);ydot=ydot'4x=fminbnd(mymin,0,pi);-mymin(x)function fx=mymin(x)fx=-sin(x)-cos(x.2);5x,y1=fminbnd(mymax,0,1.5);-y1function fx=mymax(x);fx=-(9*x+4*x.3-12*x.2);unit7實驗指導1( 1)-format longfx=inline('sin(x)./x');I,n=quadl(fx,0,2,1e-10)( 2 )format longfx=inline(&
23、#39;1./(x-0.3).2+0.01)-1./(x-0.9).2+0.04)-6');-I,n=quad(fx,0,1,1e-10)2 ( 1 )global ki;ki=0;I=dblquad(fxy,0,1,0,1)ki( 2)f=inline('abs(cos(x+y)','x','y');I=dblquad(f,0,pi,0,pi)3X=0.3:0.2:1.5;F=0.3895,0.6598,0.9147,1.1611,1.3971,1.6212,1.8325;trapz(X,F)4p=0:pi/5:2*pi;for n=1
24、:3nDX=diff(sin(p),n)end5f=inline('sin(x)./(x+cos(2.*x)');g=inline('(cos(x).*(x+cos(2*x)-sin(x).*(1-2.*sin(2*x)/(x+cos(2.*x).2'); x=-pi:0.01:pi;p=polyfit(x,f(x),5);dp=polyder(p);在假設點的函數% dp求dpx=polyval(dp,x);值 直接 %dx=diff(f(x,3.01)/對f(x)求數值導數在假設點的導數g的導函f %求函數0.01; gx=g(x);數作圖 %plot(x,
25、dpx,x,dx,'.',x,gx,'-');思考練習2format longfx=inline('1./(1+x.2)');I,n=quad(fx,-Inf,Inf,1e-10)I,n=quadl(fx,-Inf,Inf,1e-10)-x=-100000:100000;y=1./(1+x.2);trapz(x,y)format short3(1)format longfx=inline('log(1+x)./(1+x.2)'); I,n=quad(fx,0,1,1e-10)-(2)format longfx=inline(
26、9;sqrt(cos(t.2)+4*sin(2*t).2)+1)');I=triplequad(f,0,pi,0,pi,0,1)5f=inline('sin(x)'); g=inline('cos(x)'); x=0:0.01:2*pi; p=polyfit(x,f(x),5);dp=polyder(p);dpx=polyval(dp,x);dx=diff(f(x,2*pi+0.01)/0.01;gx=g(x);plot(x,dpx,x,dx,'.',x,gx,'-')unit8實驗指導1syms x y;s=x4-y4;
27、factor(s)factor(5135)2syms x;f=(x-2)/(x2-4);limit(f,x,2)sym x;f=(sqrt(pi)-sqrt(acos(x)/sqrt(x+1);limit(f,x,-1,'right')3sym x;-f=sin(1/x);diff(f,'x')diff(f,'x',2)sym x;-f=(1-cos(2*x)/x;diff(f,'x') diff(f,'x',2) 4 sym x; f=sqrt(exp(x)+1);int(f,'x')syms x
28、 y;f=x/(x+y);int(f,'y')sym x;f=exp(x)*(1+exp(x)2;int(f,'x',0,log(2)sym x;f=x*log(x);int(f,'x',1,exp(1)s=symsum(-1)(x+1)/x,1,Inf)sym y;5sym x;z=symsum(y(2*y-1)/(2*y-1),1,Inf)6sym x;f1=(exp(x)+exp(-x)/2; f2=sqrt(x3-2*x+1); taylor(f1,x,5,0)taylor(f2,x,6,0)7syms x y a;x=solve(
29、9;x3+a*x+1=0','x')x=solve('sin(x)+2*cos(x)-sqrt(x)=0','x')x y=solve('log(x/y)=9','exp(x+y)=3','x','y')-8syms n;x,y=dsolve('x*(D2y)+(1-n)*(Dy)+y=0','y(0)=0','Dy(0)=0','x')思考練習2syms x B1 B2 a b-s1=2*(cos(x)2)-(sin(x)2;s2=sin(B1)*cos(B2)-cos(B1)*sin(B2);s3=sqrt(a+sqrt
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 《財務報表分析實訓課件》課件
- 2025年江蘇省揚州市高郵市中考物理一模試卷(含解析)
- 《電子產品跟單銷售流程》課件
- 短途行程協議
- 《GB 16174.1-2015手術植入物 有源植入式醫療器械 第1部分:安全、標記和制造商所提供信息的通 用要求》(2025版)深度解析
- 鐵路市場營銷市場細分的方法課件
- 云南水池補漏施工方案
- 《GB 16787-199730 MHz~1GHz 聲音和電視信號的電纜分配系統輻射測量方法和限值》(2025版)深度解析
- 中國主要氣象災害
- 中醫面部知識培訓課件視頻
- Academic English智慧樹知到答案2024年杭州醫學院
- 廣東省深圳市龍崗區南灣實驗小學2023-2024學年四年級下學期期中測試數學試題
- 車輛應急預案方案惡劣天氣
- 安徽省合肥六校聯盟2022-2023學年高一下學期期中聯考化學試題(解析版)
- 提高感染性休克集束化治療完成率工作方案
- pvc輸送帶生產工藝
- 宮頸肌瘤的護理查房
- 稅收學 課件 第一章稅收與稅法概述
- 可行性研究報告編制服務投標方案
- 四年級數學下冊《平移》課件公開課
- 美世國際職位評估體系IPE3.0使用手冊
評論
0/150
提交評論