Writing a loop to create a matrix
1 次查看(过去 30 天)
显示 更早的评论
if N==1
Lambda = A;
elseif N==2
Lambda = [A A^2]';
elseif N==3
Lambda = [A A^2 A^3]';
elseif N==4
Lambda = [A A^2 A^3 A^4]';
elseif N==5
Lambda = [A A^2 A^3 A^4 A^5]';
end
Given that A is a matrix, how do I create a loop that creates:
Lambda = [A A^2 A^3... A^(N-2) A^(N-1) A^N]';
0 个评论
采纳的回答
Davide Masiello
2022-5-2
编辑:Davide Masiello
2022-5-2
Example
A = rand(3)
n = 10;
lambda = [];
for i = 1:n
lambda = [lambda;A.^i];
end
lambda
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!