您的当前位置:首页正文

mat

2024-09-10 来源:年旅网
 12 13 14 实验一:

17 18 19 第2题

>> t=[-1,0,1]; 第4题 >> >> A=magic(5) y=(sqrt(3)/2)*exp(-4*t).*sin(4*sqrt(3*t)+pi/3) A = y = 17 24 1 8 15 1.0e+004 * 23 5 7 14 16 2.0897 + 1.2065i 0.0001 0.0000 第3题

>> A=[1 2 3 4 5;6 7 8 9 10;11 12 13 14 15;16 17 18 19 20;21 22 23 24 25] A = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 >> I=[2 3 4] I = 2 3 4 >> J=[2 3 4] J = 2 3 4 >> A(I,J) ans = 7 8 9 4 6 13 20 10 12 19 21 11 18 25 2 >> p=[1 3 2 4 5]'

p = 1 3 2 4 5 >> A(p,:) ans = 17 24 1 8 4 6 13 20 23 5 7 14 10 12 19 21 11 18 25 2 第5题 >> a=[1 4 -3;2 5 -1;1 6 1]; >> >> b=[2 11 12]; >> >> a=[1 4 -3;2 5 -1;1 6 1] a = 1 4 -3 2 5 -1

22 3 9 15 22 16 3 9 1 6 1

>> b=[2 11 12]' b =

2 11 12

>> x=inv(a)*b x =

4.0000 1.0000 2.0000 第6题

>> p=[1 -6 -72 -27] p =

1 -6 -72

>> roots(p)

ans =

12.1229 -5.7345 -0.3884 第7题

>> x=[1 2 3 4 ] x =

1 2 3

>> y=[1 4 9 16] y =

1 4 9 -27 4 16 >> r=conv(x,y) r =

1 6 20 50 75 84 64

>> [r,p]=deconv(x,y) r =

1 p =

0 -2 -6 -12 第8题

>> r=[-5 -3+4i -3-4i]; >> poly(r)

ans =

1 11 55 125

>> A=[2 3 4;1 5 7;6 2 5] A =

2 3 4 1 5 7 6 2 5

>> sort(A,1)

ans =

1 2 4 2 3 5 6 5 7 第9题

>> A=[2 3 4;1 5 7;6 2 5]

A =

2 3 4 1 5 7 6 2 5

>> [r,p]=sort(a) r =

1 4 -3 1 5 -1 2 6 1 p =

1 1 1 3 2 2 2 3 3

>> pos=p(:,1)

pos =

1 3 2

>> a(pos,:)

ans =

1 4 -3 1 6 1 2 5 -1

>> A=[2 3 4;1 5 7;6 2 5] A =

2 3 4 1 5 7 6 2 5

>> [r,p]=sort(a) r =

1 4 -3 1 5 -1 2 6 1 p =

1 1 1 3 2 2 2 3 3

>> pos=p(:,1)

pos =

1 3 2

>> a(pos,:)

ans =

1 4 -3 1 6 1 2 5 -1

>> A=[2 3 4;1 5 7;6 2 5] A =

2 3 4 1 5 7 6 2 5

>> [r,p]=sort(A) r =

1 2 4 2 3 5 6 5 7 p =

2 3 1 >>

>> [r,p]=sort(A,2) r =

2 3 4 1 5 7 2 5 6 1 1 3 2

>> pos=p(:,1)

pos =

2 1 3

>> A(pos,:)

ans =

1 5 2 3 6 2

>> pos=p(:,2)

pos =

3 1 2

>> A(pos,:)

ans =

6 2 2 3 1 5 3 2 7 4 5 5 4 7 p =

1 2 1 2 2 3

>> pos=p(1,:)

pos =

1 2

>> pos'

ans =

1 2 3

>> A(pos,:)

ans =

2 3 1 5 6 2

3 3 1 3 4 7 5 实验四:

>> a={magic(5),'abc';15,rand(2,3)} a = [5x5 double] 'abc' [ 15] [2x3 double] >> save filea.mat >> whos Name Size Bytes Class A 2x2 32 double array a 2x2 502 cell array c 2x2 272 cell array Grand total is 51 elements using 806 bytes >> clear all >> whos >> load filea.mat >> whos Name Size Bytes Class A 2x2 32 double array a 2x2 502 cell array c 2x2 272 cell array Grand total is 51 elements using 806 bytes 2 >> pwd ans = d:\\Program Files\\MATLAB71\\work >> img=importdata('zhb.jpg'); >> r=im2double(img); >> desing=[r<0.35].*r*0.3+[r<=0.65&r>=0.35].* (0.105+2.6333*(r-0.35))+[r>0.65].*(1+0.3*(r- 1)); >> image(desing) >> imwrite(desing,'axc.jpg') >>

>> load aa.txt >> x=aa(:,1) x = 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 >> y=aa(:,2) y = 11.3456 11.3566 11.3677 11.3789

11.4014 11.4146 12.2346 12.3456 12.3562 12.4578

>> plot(x,y) >>

sond=importdata('NO.WAV')

sond =

data: [9344x1 double] fs: 16000

>> sound(sond.data,sond.fs)

>> sond.data=sond.data([9344:-1:1])

sond =

data: [9344x1 double] fs: 16000

wavwrite(sond.data,sond.fs,'zhb.wav') >> sound(sond.data,sond.fs)

实验五: 第一题

data=[3000,2334,3444,6663;2342,3422,2111,4453;3232,2334,5433,3500]; bar(data);

title('各品牌销售比较图');

legend('2006','2007','2008','2009');

set(gca,'xticklabel',['海尔';'联想';'方正']) grid on

第二题 z=0:0.1:40; x=cos(z).^2; y=sin(z)+cos(z); plot3(z,x,y)

xlabel('x') ylabel('y') zlabel('z')

title('spiral plot-using plot3')

第三题

x=-2*pi:0.1:2*pi; y=sin(x)+x;

k5=polyfit(x,y,5); k7=polyfit(x,y,7); k9=polyfit(x,y,9); newy5=polyval(k5,x); newy7=polyval(k7,x); newy9=polyval(k9,x);

plot(x,y,'k',x,newy5,'r',x,newy7,'b',x,newy9,'g');

legend('origin curce','5th order','7th order','9th order')

第四题 x=0:50:450; y=0:50:450;

[x1,y1]=meshgrid(x,y); z=10*randn(10,10)+20; subplot(1,2,1); surf(x1,y1,z); xi=0:50:450; yi=0:50:450;

[xi1,yi1]=meshgrid(xi,yi);

zi1=interp2(x1,y1,zxi1,yi1,'spline'); subplot(1,2,2); surf(xi1,yi1,zi1);

因篇幅问题不能全部显示,请点此查看更多更全内容