13.
a=[6,9,3;2,7,5]; b=[2,4;4,6;1,8]; a*b
ans =
51 102
37 90 14.
A=[4,9,2;7,6,4;3,5,7]; B=[37;26;28]; X=inv(A)*B X =
-0.5118 4.0427 1.331815. syms x
solve('x^3-7*x^2+2*x+4=0') 15. syms x
solve('x^3-7*x^2+2*x+40=0') ans = -2 4 5 16. x=8;
y=(x-1)*(x-2)*(x-3)*(x-4) y =
840 17. syms x
y=3*x^3+13*x^2+6*x+8; A=factor(y); B=A/(x+4) B =
3*x^2 + x + 218. 18. syms x
y=sqrt(4*x^4-12*x^3-14*x^2+5*x+9); df=diff(y) df =
-(- 16*x^3 + 36*x^2 + 28*x - 5)/(2*(4*x^4 - 12*x^3 - 14*x^2 + 5*x + 9)^(1/2)) syms x
f=4*x^4-12*x^3-14*x^2+5*x+9; nf=int(f) nf =
(4*x^5)/5 - 3*x^4 - (14*x^3)/3 + (5*x^2)/2 + 9*x 19. 20.
t=0.1:0.1^5*pi:2*pi; x=sin(3*t)*cos(t); y=xin(3*t)*sin(t); plot(x,y) 21.
x=0:0.01:10; y1=exp(-0.1*x); y2=exp(-0.2*x); y3=exp(-0.5*x);
plot(x,y1,'b',x,y2,'R',x,y3,'k') xlabel('x') ylabel('y')
title('Sine and Cosine Curve') gtext('y=exp(-0.1*x)') gtext('y=exp(-0.2*x)') gtext('y=exp(-0.5*x)')
22.
t=-2:0.1^3:2; y1=2*sin(t*pi);
y2=2*sin(t*pi)+0.1*sin(t*pi); plot(t,y1,'r',t,y2,'k')
title('Sine and Cosine Curve') gtext('y=2*sin(t*pi)')
gtext('y=2*sin(t*pi)+0.1*sin(t*pi)'
23.(你找别人的看下,这个可能有点问题)
A=rand(1,1); a=A(1,1);
fprintf('a=%.0f\\n ',a); t=1; while t==1
if mod(a,2)==0; a=a/2;
fprintf('a=%.0f\\n ',a); else a=a*3+1;
fprintf('a=%.0f\\n ',a); end if a==1 t=0;
fprintf('a=%.0f\\n ',a); else t=1; end end
24.
a=[4,2,-6;7,5,4;3,4,9]; det(a) inv(a)
ans =
-64
ans =
-0.4531 0.6562 -0.5937 0.7969 -0.8437 0.9062 -0.2031 0.1562 -0.0937 25. syms t
solve('a*t^2+b*t+c=0') ans =
-(b + (b^2 - 4*a*c)^(1/2))/(2*a) -(b - (b^2 - 4*a*c)^(1/2))/(2*a) 二. 2.
syms x
f='[a,x^2,1/x;exp(a*x),log(x),sin(x)]'; diff(f,x) ans =
[ 0, 2*x, -1/x^2] [ a*exp(a*x), 1/x, cos(x)] 3.
x=-2:0.1:2; y=x;
[x,y]=meshgrid(x,y); subplot(2,2,1) z=x*exp(-x^2-y^2); plot3(x,y,z) subplot(2,2,2) mesh(x,y,z) subplot(2,2,3) surf(x,y,z)
相关推荐: