武汉烟草专卖局:帮忙写个matlab小程序

来源:百度文库 编辑:神马品牌网 时间:2024/08/28 04:16:42
求任一矩阵的一次方加二次方一直回到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