Help to make code into a for loop
显示 更早的评论
Hello,
I would like to know how to go about making the following code into a for loop:
A1 = [0 1 0; 0 0 0; 0 0 1]
%fprintf('%f\n', A1);
rankA1 = rank(A1);
fprintf('Rank of A1 is %5.0d\n', rankA1);
[r,c] = size(A1);
nullityA1 = c - rankA1;
fprintf('Nullity of A1 is %5.0d\n', nullityA1);
A2 = [4 1 -1; 3 2 0; 1 1 0]
rankA2 = rank(A2);
fprintf('Rank of A2 is %5.0d\n', rankA2);
[r,c] = size(A2);
nullityA2 = c - rankA2;
fprintf('Nullity of A1 is %5.1d\n', nullityA2);
A3 = [1 2 3 4; 0 -1 -1 2; 0 0 0 1]
rankA3 = rank(A3);
fprintf('Rank of A3 is %5.0d\n', rankA3);
[r,c] = size(A3);
nullityA3 = c - rankA3;
fprintf('Nullity of A3 is %5.0d\n', nullityA3);
The code after the matrices A1, A2 and A3 is basically the same except for the variables. Thanks for your help.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB Mobile 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!