《MATLAB及其在大学物理课程中的应用》习题答案___电子科大__第二版

时间:2025-07-05

第二章

1、

x=[2,4];

y=x.^3+(x-0.98).^2./(x+1.35).^3-5*(x+1./x)

2、

y=cos(pi/3)-(9-sqrt(2))^(1/3)

3、

a=3;A=4;

b=a.^2;

B=b.^2-1;

c=a+A-2*B;

C=a+2*B+c

4、x=[1 2 3;4 5 6;7 8 9]

Desktop->Workspace,双击变量x

5、

clear

x=magic(3)

y=randn(3,3)

xy=[x,y]

yx=[x,y]

z=xy(:,1:2)

6、

clear

x=eye(4,4)

y=triu(x)

7、

clear

x=rand(4,5)

y=x([1,2],:)

z=(y>=0.3).*y

8、

clear

x=randn(5,5)

y=inv(x)

9、

clear

x=randn(5,5)

z=x^5

10、

clear

A=[1,4,8;-3,6,-5;2,-7,-12];

B=[5,4,3;6,-2,3;-1,3,-9];

C=A*B

D=A.*B

11、

clear

x=linspace(0,2*pi,125);

y=cos(x).*(0.5+3*sin(x)./(1+x.^2));

plot(x,y)

12、

z=-45:1:45;

x=z.*sin(3*z);y=z.*cos(3*z);

plot3(x,y,z);

13、

x=-2:0.1:2,y=x;

[x,y]=meshgrid(x,y);

z=x.^2.*exp(-x.^2-y.^2)

surf(x,y,z);

14、

x=-2:0.1:2,y=x;

[x,y]=meshgrid(x,y);

z=x.^2.*exp(-x.^2-y.^2);

surf(x,y,z);

z1=0.05*x-0.05*y+0.1;

hold on,mesh(x,y,z1);

15、

(1)

n=2;alfa=0;

t=0:0.1:10;x=cos(t);y=sin(n*t+alfa);

subplot(2,2,1);plot(t,x,t,y);

(2)

n=2;alfa=0;

t=0:0.1:10;x=cos(t);y=sin(n*t+alfa);

subplot(2,2,1);plot(t,x,t,y);

n=2;alfa=pi/3;

t=0:0.1:10;x=cos(t);y=sin(n*t+alfa);

subplot(2,2,2);plot(t,x,t,y);

n=2;alfa=pi/2;

t=0:0.1:10;x=cos(t);y=sin(n*t+alfa);

subplot(2,2,3);plot(t,x,t,y);

n=2;alfa=pi;

t=0:0.1:10;x=cos(t);y=sin(n*t+alfa);

subplot(2,2,4);plot(t,x,t,y);

球体

clear

for i=1:100

for j=1:100

x(i,j)=i/100*cos(j*2*pi/100);

y(i,j)=i/100*sin(j*2*pi/100);

z(i,j)=sqrt(1.001-x(i,j)^2-y(i,j)^2);

end

end

surf(x,y,z);hold on;surf(x,y,-z);axis equal

棱锥

clear

for i=1:100

for j=1:100

x(i,j)=i/100*cos(j*2*pi/4);

y(i,j)=i/100*sin(j*2*pi/4);

z(i,j)=sqrt(x(i,j)^2+y(i,j)^2);

end

end

surf(x,y,-z);

求最大值

x=[67 87 56 99 43]

max=0;

for i=1:5

if max>=x(i)

max=max;

else max=x(i)

end

end

max

求最小值

x=[67 87 56 99 43]

min=inf;

for i=1:5

if min<=x(i)

min=min;

else min=x(i)

end

end

min

求和

x=[67 87 56 99 43];

sum=0;

for i=1:5

sum=sum+x(i)

end

sum

第三章

1、

h0=[446,714,950,1422,1634];

t0=[7.04,4.28,3.40,2.54,2.13];

t1=interp1(h0,t0,500,'linear')

2、

x0=[1,0,-1];y0=[0,1,0];

p=polyfit(x0,y0,3);

x=-1:0.1:1;

y=polyval(p,x);

plot(x,y,-x,-y),axis equal

3、

clear

x0=[1.0,1.1,1.2,1.3,1.4];

y0=[0.25,0.2268,0.2066,0.1890,0.1736];

p=polyfit(x0,y0,3);

p1=polyder(p);

y=polyval(p1,[1.0,1.2])

4、

p=[3 4 7 2 9 12];

r=roots(p)

5、

r=[-3 -5 -8 -9];

p=poly(r)

6、

function ypie=fun1(x,y)

ypie=x.^2./y-x.*cos(y);

[x,y]=ode45('fun1',[0,5],1)

plot(x,y)

7、

function y=fun2(x)

y=x.^4-3*x^3+5*cos(x)+8;

fplot('fun2',[1,5])

hold on;x=0:5;y=0*x;plot(x,y)

a=fzero(@fun2,2)

b=fzero(@fun2,3)

8、

a=[2 4 9;4 2 4;9 4 18];

[v,gama]=eig(a)

9、

function xpie=fun3(t,x)

f=exp(-t)

xpie=[0 1 0 0;1 0 0 -1;0 0 0 1;0 -1 -1 0]*x+[0;1;0;0]*f

[t,x]=ode45('fun3',[0,5],[0 0 0 0]');

plot(t,x(:,1),'b',t,x(:,3),'r')

10、

function f=fun4(x,y)

f=4*(x-y)-x.^2-y.^2;

v=-2:0.2:2;

[x,y]=meshgrid(v)

z=fun4(x,y);

surf(x,y,z)

求极小值 (有误)

function f=fun5(x,y)

x=v(1);y=v(2)

f=-(4*(x-y)-x.^2-y.^2);

v=-50:2:50;

[x,y]=meshgrid(v)

z=fun4(x,y);

surf(x,y,z)

min=fminsearch('fun4',[0,0])

11、

function f=fun6(x,y)

f=sin(y)+exp(x)-x.*y.^2

ezplot('fun6')

12、

function f=fun7(x,y)

f=(x-y).^2.*(sin(x+y)).^2

s=dblquad('fun7',pi,2*pi,0,pi)

14、

a=randn(4,4)

[l,u]=lu(a)

a=randn(4,4)

[u,gama,v]=svd(a)

15、

b=[3 0.5 4];a=[3 4 5 6];

[r,p,k]=residue(b,a)

b=[3 0.5 4];a=[3 4 5 6];

[r,p,k]=residue(b,a)

t=0:0.1:100;y=0*t;

for i=1:3

y=y+r(i)*exp(p(i)*t)

end

plot(t,y)

b=[3 0.5 4];a=[3 4 5 6];

impulse(b,a)

b=[3 0.5 4];a=[3 4 5 6];

step(b,a)

第四章

1、

n=1:11;x=cos(pi/6*n);

subplot(2,1,1);stem(x);

y=abs(fft(x));

subplot(2,1,2);stem(y);

clear

n=0:11;x=cos(pi/6*n);

subplot(2,1,1);stem(x);

y=abs(fft(x));

subplot(2,1,2);stem(y);

2、(有误)

n=0:19;x=5*0.6.^n;

subplot(3,1,1);stem(n,x);

for i=-20:39

xl(i+21)=x(mod(i+40,20)+1);

end

n1=-20:39;

subplot(3,1,2);stem(n1,x1);

x2=x1(10:29);

subplot(3,1,3);stem(n,x2)

新方法

m=10;

e=0:19;

c=0.6;k=5;

a=k*c.^e;

a=a';

b=circshift(a,m);

L=length(a)-1;

n=0:L;

subplot(2,1,1);

stem(n,a);

axis([0,L,min(a),max(a)]);

subplot(2,1,2);

stem(n,b);

axis([0,l,min(a),max(a)])

3、

x=[0.8 0.8 0.8 0.8 0.8 0.8 …… 此处隐藏:3602字,全部文档内容请下载后查看。喜欢就下载吧 ……

《MATLAB及其在大学物理课程中的应用》习题答案___电子科大__第二版.doc 将本文的Word文档下载到电脑

    精彩图片

    热门精选

    大家正在看

    × 游客快捷下载通道(下载后可以自由复制和排版)

    限时特价:7 元/份 原价:20元

    支付方式:

    开通VIP包月会员 特价:29元/月

    注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
    微信:fanwen365 QQ:370150219