
答:a=[6,9,3;2,7,5];
b=[2,4,1;4,6,8];
c=a.*b
c =
12 36 3
8 42 40
14 对于,如果,,求解X。
答:A=[4,9,2;7,6,4;3,5,7];
B=[37,26,28];
X=A/B
X =
0.1548
0.1863
0.1545
15,求解多项式x3-7x2+2x+40的根。
答:a=[1 -7 2 40];
x=roots(a)
x =
5.0000
4.0000
-2.0000
16,求解在x=8时多项式(x-1)(x-2) (x-3)(x-4)的值。
答:x=8;
y=(x-1)*(x-2)*(x-3)*(x-4)
y =
840
17,计算多项式除法(3x3+13x2+6x+8)/(x+4)。
答:a=[3 13 6 8];
b=[1 4];
[c,d]=deconv(a,b)
c =
3 1 2
d =
0 0 0 0
18,计算多项式的微分和积分。
答:syms f x;
f=4*x^4-12*x^3-14*x^2+5*x+9;
df=diff(f)
intf=int(f)
df =
16*x^3 - 36*x^2 - 28*x + 5
intf =
(4*x^5)/5 - 3*x^4 - (14*x^3)/3 + (5*x^2)/2 + 9*x
19, 有一正弦衰减数据y=sin(x).*exp(-x/10),其中x=0:pi/5:4*pi,用三次样条法进行插值。
答:x0=0:pi/5:4*pi;
y0=sin(x0).*exp(-x0/10);
x=0:pi/10:4*pi;
y=spline(x0,y0,x)
plot(x0,y0,'or',x,y,'k')
y =
Columns 1 through 5
0 0.3028 0.5520 0.7349 0.8387
Columns 6 through 10
0.8545 0.7877 0.91 0.4572 0.2330
Columns 11 through 15
0.0000 -0.2185 -0.4032 -0.5375 -0.6126
Columns 16 through 20
-0.6240 -0.5753 -0.4741 -0.3339 -0.1701
Columns 21 through 25
-0.0000 0.1596 0.2945 0.3926 0.4475
Columns 26 through 30
0.4557 0.4202 0.3463 0.2439 0.1243
Columns 31 through 35
0.0000 -0.1166 -0.2151 -0.2867 -0.3268
Columns 36 through 40
-0.3329 -0.3069 -0.2529 -0.1781 -0.0911
Column 41
-0.0000
20,用符号函数绘图法绘制函数x=sin(3t)cos(t),y=sin(3t)sin(t)的图形,t的变化范围为[0,2]。
答:syms t;
x=sin(3*t).*cos(t);
y=sin(t).*cos(3*t);
subplot(1,2,1);
ezplot(x,[0,2*pi]);
grid;
subplot(1,2,2);
ezplot(y,[0,2*pi]);
grid;
21,有一组测量数据满足,t的变化范围为0~10,用不同的线型和标记点画出a=0.1、a=0.2和a=0.5三种情况下的曲线,并添加标题,用箭头线标识出各曲线a的取值,添加标题和图例框。
答:t=0:0.1:10;
a=0.1;
y1=exp(-a*t);
a=0.2;
y2=exp(-a*t);
a=0.5;
y3=exp(-a*t);
subplot(1,2,1);
plot(t,y1,'-',t,y2,':',t,y3);
title('y=exp(-a*t)','FontSize',20);
xlabel('t','FontSize',16);ylabel('y','FontSize',16);
text(4,exp(-0.1*4),'\\leftarrowa=0.1','FontSize',16);
text(4,exp(-0.2*4),'\\leftarrowa=0.2','FontSize',16);
text(4,exp(-0.5*4),'\\leftarrowa=0.5','FontSize',16);
subplot(1,2,2);
plot(t,y1,'o',t,y2,'*',t,y3,'.');
title('y=exp(-a*t)','FontSize',20);
xlabel('t','FontSize',16);ylabel('y','FontSize',16);
text(4,exp(-0.1*4),'\\leftarrowa=0.1','FontSize',16);
text(4,exp(-0.2*4),'\\leftarrowa=0.2','FontSize',16);
text(4,exp(-0.5*4),'\\leftarrowa=0.5','FontSize',16);
22,建立一个简单模型,用信号发生器产生一个幅度为2V、频率为0.5Hz的正 弦
波,并叠加一个0.1V的噪声信号,将叠加后的信号显示在示波器上并传送到
工作空间。
答:
23编制一个解数论问题的函数文件:取任意整数,若是偶数,则用2除,否则乘3加1,重复此过程,直到整数变为1。
答:clear
clc
m=input('ÊäÈëÕýÕûÊým=');
n=0;
while(m~=1)
if rem(m,2)==0
m=m/2;
else m=m*3+1;
m
end
n=n+1;
end
n
24, 矩阵,计算a的行列式和逆矩阵。
答:a=[4,2,-6;7,5,4;3,4,9];
deta=det(a)
inva=inv(a)
deta =
-
inva =
-0.4531 0.6562 -0.5937
0.7969 -0.8437 0.9062
-0.2031 0.1562 -0.0937
25用符号函数法求解方程at2+b*t+c=0。
答:syms a b c t;
s=a*t^2+b*t+c;
solve(s,t)
ans =
-(b + (b^2 - 4*a*c)^(1/2))/(2*a)
-(b - (b^2 - 4*a*c)^(1/2))/(2*a)
二、选答题(在下列题中选答5题):
2., 用符号微分求df/dx。
答:syms a x;
f=[a,x^2,1/x;exp(a*x),log(x),sin(x)];
df=diff(f)
df =
[ 0, 2*x, -1/x^2]
[ a*exp(a*x), 1/x, cos(x)]
3.,当x和y的取值范围均为-2到2时,用建立子窗口的方法在同
一个图形窗口中绘制出三维线图、网线图、表面图和带渲染效果的表面图。
答:subplot(2,2,1);
x=-2:2;
y=-2:2;
z=x.*exp(-x.^2-y.^2);
plot3(x,y,z);
grid on;
title('三维线图 ');
xlabel('x');ylabel('y');zlabel('z');
subplot(2,2,2);
syms x y;
z=x*exp(-x^2-y^2);
ezmesh(z,[-2,2,-2,2],40);
title('网线图');
xlabel('x');ylabel('y');zlabel('z');
subplot(2,2,3);
syms x y;
z=x*exp(-x^2-y^2);
ezsurf(x,y,z,[-2,2,-2,2],40);
title('表面图');
xlabel('x');ylabel('y');zlabel('z');
subplot(2,2,4);
syms x y;
z=x*exp(-x^2-y^2);
ezsurf(x,y,z,[-2,2,-2,2],80);
shading interp;
daspect([3 3 1])
axis tight
light('position',[-10,-10,21])
title('带渲染的表面图');
xlabel('x');ylabel('y');zlabel('z');
4.用subplot语句在一个图形窗口上开多个大小不等的子窗口进行绘图并添加注
释,见图。图形具体内容及各图所占位置可自选。
答:subplot(2,3,[1,4]);
yn=randn(10000,1);
hist(yn,20);
xlabel('直方图');
subplot(2,3,3);
syms x y
ezsurfc(y/(1+x^2+y^2),[-5,5,-2*pi,2*pi],35)
view(-65,26)
xlabel('三维图');
subplot(2,3,2);
t=0:.01:2*pi;
h4=polar(t,sin(2*t).*cos(2*t));
xlabel('极坐标图');
subplot(2,3,[5,6]);
x=0:0.3:12;
y=exp(-0.3*x).*sin(x)+0.5;
plotyy(x,y,x,y,'plot','stem');
xlabel('带标记点的线图');
annotation(gcf,'textbox','String',{'多窗口绘图示例 '},'FontSize',16,'Position',[0.4 0.88 0.24 0.12],'edgecolor',get(gcf,'color'))
