您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 公司方案 > MATLAB基础教程-薛山-课后答案[2-12章].khda
21double(1)a=87b=190a+ba-ba*b(2)uint8(1)1a=87a=87b=190b=190a+bans=277a-bans=-103a*bans=165302c=uint8(87)c=87d=uint8(190)d=190c+dans=255c-dans=0c*dans=2552(1)sin60(2)e3(3)3cos41sind(60)ans=0.86602exp(3)ans=20.08553cos(3*pi/4)ans=-0.707132u3v(1)4loguvv(2)22euvvu(3)3uvuv1u=2;v=3;4*u*v/log(v)ans=21.84572(exp(u)+v)^2/(v^2-u)ans=15.41893sqrt(u-3*v)/(u*v)ans=0+0.4410i4(1)3542ii(2)sin28i1(3-5*i)*(4+2*i)ans=22.0000-14.0000i2sin(2-8*i)ans=1.3553e+003+6.2026e+002i5(1)420(2)4=20(3)4==20(4)4~=20(5)'b''B'1420ans=124=20ans=134==20ans=044~=20ans=15'b''B'ans=0639a58b3c7d(1)ab(2)ac(3)&&abbc(4)ad(5)|abc(6)~~d1a=39;b=58;c=3;d=7;abans=02acans=03ab&&bcans=04a==dans=05a|bcans=16~~dans=172disp('sin(60)=');disp(sind(60));disp('exp(3)=');disp(exp(3));disp('cos(3*pi/4)=');disp(cos(3*pi/4));86a=39;b=58;c=3;d=7;disp('ab'),disp(ab);disp('ac'),disp(ac);disp('ab&&bc'),disp(ab&&bc)disp('a==d'),disp(a==d);disp('a|bc'),disp(a|bc);disp('~~d'),disp(~~d);31.x=[93063]y=mod((sqrt(length(((x+5).*[12345]))*5)),3)yy=22.MATLABa=[3,7,2,7,9,3,4,1,6];b=[7];a(4)=[];vec1=a==b;vec2=mod(a,2)==0;c=sum(vec1);vec3=vec1+vec2;d=vec3.*a;vec4=find(a5);e=a(vec4)+5;vec5=find(a5);f=vec5.^2;cdefc=1,d=[0,7,2,0,0,4,0,6],e=[12,14,11],f=[1,9,25,36,49]3.4.2,14,11],f=[1,9,25,36,49]2,14,11],f=[1,9,25,36,49]2,14,11],f=[1,9,25,36,49]2,14,11],f=[1,9,25,36,49]41.X11.11.21.31.4y1.000001.233681.552711.993722.611700.05%Interpolationusingthefourmethodsx=[11.11.21.31.4];y=[1.000001.233681.552711.993722.61170];length_of_x=length(x);scalar_x=x(1):0.05:x(length_of_x);length_of_sx=length(scalar_x);y_nearest=zeros(length(scalar_x),1);y_linear=zeros(length(scalar_x),1);y_spline=zeros(length(scalar_x),1);y_cubic=zeros(length(scalar_x),1);fori=1:length_of_sxy_nearest(i)=interp1(x,y,scalar_x(i),'nearest');y_linear(i)=interp1(x,y,scalar_x(i),'linear');y_spline(i)=interp1(x,y,scalar_x(i),'spline');y_cubic(i)=interp1(x,y,scalar_x(i),'cubic');endsubplot(2,2,1),plot(x,y,'*'),holdon,plot(scalar_x,y_nearest),title('method=nearest');subplot(2,2,2),plot(x,y,'*'),holdon,plot(scalar_x,y_linear),title('method=linear');subplot(2,2,3),plot(x,y,'*'),holdon,plot(scalar_x,y_spline),title('method=spline');subplot(2,2,4),plot(x,y,'*'),holdon,plot(scalar_x,y_cubic),title('method=cubic');y_cubic=zeros(length(scalar_x),1);y_cubic=zeros(length(scalar_x),1);y_nearest(i)=interp1(x,y,scalar_x(i),y_nearest(i)=interp1(x,y,scalar_x(i),y_linear(i)=interp1(x,y,scalar_x(i),y_linear(i)=interp1(x,y,scalar_x(i),y_spline(i)=interp1(x,y,scalar_x(i),y_spline(i)=interp1(x,y,scalar_x(i),y_cubic(i)=interp1(x,y,scalar_x(i),y_cubic(i)=interp1(x,y,scalar_x(i),'nearest''nearest'););y_linear(i)=interp1(x,y,scalar_x(i),'linear''linear'y_spline(i)=interp1(x,y,scalar_x(i),y_spline(i)=interp1(x,y,scalar_x(i),'spline''spline'y_cubic(i)=interp1(x,y,scalar_x(i),y_cubic(i)=interp1(x,y,scalar_x(i),'cubic''cubic'),hold),hold,plot(scalar_x,y_nearest),title(,plot(scalar_x,y_nearest),title('method=nearest'subplot(2,2,2),plot(x,y,'*'),hold),hold,plot(scalar_x,y_linear),title(,plot(scalar_x,y_linear),title(subplot(2,2,3),plot(x,y,subplot(2,2,3),plot(x,y,'*''*'),hold,plot(scalar_x,y_spline),title(,plot(scalar_x,y_spline),title(subplot(2,2,4),plot(x,y,2.(1)5exyx8x(2)sinyxx1y=@(x)exp(x)-x^5;x=fzero(y,8)x=12.7132fplot(y,[x-1,x+1]);holdonplot(x,y(x),'r*');2y=@(x)x*sin(x);x=03.(1)221zxy(2)21zxy1z=@(x)x(1)^2-(x(2)-1)^2;[x,fvalue,flag,output]=fminsearch(z,[0,0])Exiting:Maximumnumberoffunctionevaluationshasbeenexceeded-increaseMaxFunEvalsoption.Currentfunctionvalue:-359212266339440800000000000000000000000000000000000000000000000000000000000000000000.000000x=1.0e+041*0.9523-6.0686fvalue=-3.5921e+083flag=0output=iterations:200funcCount:401algorithm:'Nelder-Meadsimplexdirectsearch'message:[1x233char]2z=@(x)(x(1)-x(2)+1)^2;[x,fvalue,flag,output]=fminsearch(z,[0,0])x=-0.54250.4575fvalue=2.4109e-011flag=1output=iterations:40funcCount:74algorithm:'Nelder-Meadsimplexdirectsearch'message:[1x196char]implexdirectsearch'implexdirectsearch'message:[1x233char]z=@(x)(x(1)-x(2)+1)^2;z=@(x)(x(1)-x(2)+1)^2;[x,fvalue,flag,output]=fminsearch(z,[0,0])[x,fvalue,flag,output]=fminsearch(z,[0,0])4.(1)1351dxxxx(2)1010211sindd4xyyxyx1f=@(x)x+x.^3+x.^5;q=quad(f,-1,1)q=2.2204e-016(2)f5=@(x,y)sin(y).*(x+y)./(x.^2+4);q=dblquad(f5,1,10,1,10)q=5.525451%findthetimesandplacesofthespecifiedletterinthestringletter='a';%Thespecifiedlettertobesearchedforstring='China';%Thespecifiedtringtobesearchedplaces=findstr(S,A);%Theplacesoftheletterntimes=length(places);%Thetimesoftheletter2str='thisisthestringtobeconverted';nlength=length(str);fork=1:nlengthif(k==1||isspace(str(k-1)))&&(str(k)='z'&&str(k)='a')str(k)=char(double(str(k))-32);endenddisp(str);32212doublecellA=cell(2,2);cellA(1,1)={'thefirstelementofthecell'};cellA(1,2)={'thesecondelementofthecell'};cellA(2,1)={uint8(5)};cellA(2,2)={[2,3;3,4]};4structtest=struct('name',{},'number',{},'scores',{})(k==1||
本文标题:MATLAB基础教程-薛山-课后答案[2-12章].khda
链接地址:https://www.777doc.com/doc-4851938 .html