zhangjiangwei4_1clcclearclear;x=1:10;y=[11,12,13,14,15,16,17,18];[x,y]=fexch(x,y)%fexch.m文件function[a,b]=exch(a,b)c=a;a=b;b=c;zhangjiangwei4_2clccleara=input('a=?');b=input('b=?');c=input('c=?');d=b*b-4*a*c;x=[(-b+sqrt(d))/(2*a),(-b-sqrt(d))/(2*a)];disp(['x1=',num2str(x(1)),',x2=',num2str(x(2))]);%zhangjiangwei4_3clcclearx=input('ÇëÊäÈëxµÄÖµ£º');ifx==10y=cos(x+1)+sqrt(x*x+1);elsey=x*sqrt(x*sqrt(x));endy%zhangjiangwei4_4clcclearc=input('ÇëÊäÈëÒ»¸ö×Ö·û','s');ifc='A'&c='Z'disp(setstr(abs(c)+abs('a')-abs('A')));elseifc='a'&c='z'disp(setstr(abs(c)-abs('a')+abs('A')));elseifc='0'&c='9'disp(abs(c)-abs('0'));elsedisp(c)end%zhangjiangwei4_5clcclearprice=input('¼Û¸ñ');switchfix(price/100)case{0,1}rate=0;case{2,3,4}rate=3/100;casenum2cell(5:9)rate=5/100;casenum2cell(10:24)rate=8/100;casenum2cell(25:49)rate=10/100;otherwiserate=14/100endprice=price*(1-rate)%zhangjiangwei4_6clcclearA=[1,2,3;4,5,6];B=[7,8,9;10,11,12];tryC=A*B;catchC=A.*B;endCLasterr%zhangjiangwei4_7clcclearform=100:999m1=fix(m/100);m2=rem(fix(m/10),10);m3=rem(m,10);ifm==m1*m1*m1+m2*m2*m2+m3*m3*m3disp(m)endend%zhangjiangwei4_8clccleary=0;n=100;fori=1:ny=y+1/i/i;endy%chenjiaxin4_9clccleara=0;b=3*pi;n=1000;h=(b-a)/n;x=a;s=0;f0=exp(-0.5*x)*sin(x+pi/6);fori=1:nx=x+h;f1=exp(-0.5*x)*sin(x+pi/6);s=s+(f0+f1)*h/2;f0=f1;endsZhangjiangwei5—1clcclearx1=0:pi/100:2*pi;y1=2*exp(-0.5*x1).*sin(2*pi*x1);subplot(2,2,1);plot(x1,y1)t=-pi:pi/100:pi;x2=t.*cos(3*t);y2=t.*sin(t).*sin(t);subplot(2,2,2);plot(x2,y2)x3=linspace(0,2*pi,100);y3=[sin(x3);cos(x3)];subplot(2,2,3);plot(x3,y3)t1=linspace(0,2*pi,100);x4=[t1;t1]';y4=[sin(t1);cos(t1)]';subplot(2,2,4);plot(x4,y4)Zhangjiangwei5—4clccleart1=0:pi/100:2*pi;x1=exp(i*t1);subplot(2,2,1);plot(x1)t2=0:0.01:2*pi;x2=exp(i*t2);y2=[x2;2*x2;3*x2]';subplot(2,2,2);plot(y2)x=(0:pi/100:2*pi)';y1=2*exp(-0.5*x)*[1,-1];y2=2*exp(-0.5*x).*sin(2*pi*x);x1=(0:12)/2;y3=2*exp(-0.5*x1).*sin(2*pi*x1);subplot(2,2,3);plot(x,y1,'k:',x,y2,'b--',x1,y3,'rp')x1=0:pi/100:2*pi;x2=0:pi/100:3*pi;y1=exp(-0.5*x1).*sin(2*pi*x1);y2=1.5*exp(-0.1*x2).*sin(x2);subplot(2,2,4);plot(x1,y1,x2,y2)Zhangjiangwei5—5clcclearx=linspace(0,10,100);y=[];for(x0=x)if(x0=8)y=[y,1];elseif(x0=6)y=[y,5-x0/2];elseif(x0=4)y=[y,2];elseif(x0=0)y=[y,sqrt(x0)];endendplot(x,y)axis([01002.5])title('·Ö¶Îº¯ÊýÇúÏß')xlabel('VariableX')ylabel('VariableY')text(2,1.3,'y=x{1/2}')text(4.5,1.9,'y=2')text(7.3,1.5,'y=5-x/2')text(8.5,0.9,'y=1')zhangjiangwei5_6clcclearx=(0:pi/100:2*pi)';y1=2*exp(-0.5*x)*[-1,1];y2=2*exp(-0.5*x).*sin(2*pi*x);plot(x,y1,'b:')axis([0,2*pi,-2,2]);holdon;plot(x,y2,'k');legend('°üÂçÏß','°üÂçÏß','ÇúÏßy');holdoff;grid5-7(1)clcclearx=linspace(0,2*pi,60);z=cos(x);y=sin(x);t=sin(x)./(cos(x)+eps);ct=cos(x)./(sin(x)+eps);subplot(2,2,1);plot(x,y)title('sin(x)');axis([0,2*pi,-1,1]);subplot(2,2,2);plot(x,z)title('cos(x)');axis([0,2*pi,-1,1]);subplot(2,2,3);plot(x,t)title('tangent(x)');axis([0,2*pi,-40,40]);subplot(2,2,4);plot(x,ct)title('contangent(x)');axis([0,2*pi,-40,40]);5-7(2)clcclearx=linspace(0,2*pi,60);z=cos(x);y=sin(x);t=sin(x)./(cos(x)+eps);ct=cos(x)./(sin(x)+eps);subplot(2,2,1);stairs(x,y)title('sin(x)-1');axis([0,2*pi,-1,1]);subplot(2,1,2);stem(x,y)title('sin(x)-2');axis([0,2*pi,-1,1]);subplot(4,4,3);plot(x,y)title('sin(x)');axis([0,2*pi,-1,1]);subplot(4,4,4);plot(x,z)title('cos(x)');axis([0,2*pi,-1,1]);subplot(4,4,7);plot(x,t)title('tangent(x)');axis([0,2*pi,-40,40]);subplot(4,4,8);plot(x,ct)title('contangent(x)');axis([0,2*pi,-40,40]);5-8clcclearx=0:0.35:7;y=2*exp(-0.5*x);subplot(2,2,1);bar(x,y,'g')title('bar(x,y,g)');axis([0,7,0,2]);subplot(2,2,2);stairs(x,y,'r')title('stairs(x,y,r)');axis([0,7,0,2]);subplot(2,2,3);stem(x,y,'b')title('stem(x,y,b)');axis([0,7,0,2]);subplot(2,2,4);fill(x,y,'k')title('fill(x,y,k)');axis([0,7,0,2]);5-9clccleartheta=0:0.01:2*pi;rho=sin(2*theta).*cos(2*theta);polar(theta,rho,'k')5-10clcclearx=0:0.01:10;y=10*x.*x;subplot(2,2,1);plot(x,y);title('plot(x,y)');gridon;subplot(2,2,2);semilogx(x,y)title('semilogx(x,y)');gridon;subplot(2,2,3);semilogy(x,y)title('semilogy(x,y)');gridon;subplot(2,2,4);loglog(x,y)title('loglog(x,y)');gridon;5-12clcclearsubplot(2,1,2);fplot('cos(tan(pi*x))',[-0.4,1.4],1e-4)subplot(2,2,1);pie([7,17,23,19,5])title('饼图');legend('优秀','良好','中等','及格','不及格');subplot(2,2,2);compass([3+2i,5.5-i,-1.5+5i])title('相量图‘);5-13clccleart=0:pi/50:2*pi;x=8*cos(t);y=4*sqrt(2)*sin(t);z=-4*sqrt(2)*sin(t);plot3(x,y,z,'p')title('Linein3-DSpace');text(0,0,0,'origin');xlable('X'),ylable('Y'),zlable('Z');gridon;5-14clcclearx=7:29;y=16:35;[x,y]=meshgrid(x,y);z=2*x+5*y;k=find(z==126);x(k)',y(k)'5-15(1)clcclearx=0:0.1:2*pi;[x,y]=meshgrid(x);z=sin(y).*cos(x);mesh(x,y,z)xlable('x-axis'),ylable('y-axis'),zlable('z-axis');title('mesh');(2)clcclearx=0:0.1:2*pi;[x,y]=meshgrid(x);z=sin(y).*cos(x);surf(x,y,z)xlable('x-axis'),ylable('y-axis'),zlable('z-axis');title('surf');(3)clcclearx=0:0.1:2*pi;[x,y]=meshgrid(x);z=sin(y).*cos(x);plot3(x,y,z)xlable('x-axis'),ylable('y-axis'),zlable('z-axis');title('plot3-1');5-16clcclearm=30;z=1.2*(0:m)/m;r=ones(size(z));theta=(0: