奉化市印刷排版招聘:帮忙写个matlab小程序

来源:百度文库 编辑:高考问答 时间:2024/04/30 04:59:51
求任一矩阵的一次方加二次方一直回到10次方

A=[1 3 5; 2 6 7; 3 8 2]
temp=zeros(3,3)
for n=1:10
temp=temp+A^n
end

% a is an any matrix
temp=[];
for n=1:10
temp=temp+a^n;
end

将下列程序保存为 test.m即可。
function result=test(A)
for n=1:10
result=result+A^n;
end