Matlab 课后习题集 下载本文

N=[1,2,3,4,5]; A=2*N B=N/2 C=1./N D=1./N./N

3、B=0; A=rand(1,20); for i=1:20

A(i)=fix((99-10+1)*rand(1)+10); B=A(i)+B; end A

36

页B=B/20 for i=1:20

if A(i)

4、(1)n=input('please input a number:'); s=0;

页 37

for i=1:n

if rem(i,2)==1 j=(i-1)/2; s=s+(-1)^j/i; else s=s; end end S

(2)format rat

n=input('please input a number:'); s=0; for i=1:n

38

页 s=s+1/4^i; end S

5、A=rand(3,3); B=rand(3,3);

[M,m,N,n]=chengji(A,B); A B M m N n 函数定义

39