How can generalize severel "For loop" ?
1 回表示 (過去 30 日間)
古いコメントを表示
for i=1:n
L(i,i)=1;
end
for i=2:n
L(i,1)=A(i,1)/A(1,1);
end
for i=3:n
L(i,2)=A(i,2)/A(2,2);
end
for i=4:n
L(i,3)=A(i,3)/A(3,3);
end
2 件のコメント
Mark Whirdy
2013 年 2 月 20 日
編集済み: Mark Whirdy
2013 年 2 月 20 日
Hi there
What are the values of A & n?
Could you values for all variables and the required output as well as describing what you are trying to do?
José-Luis
2013 年 2 月 20 日
This is the second time in less than an hour that the same question has been asked in the forum. Looks like the instructor recommended Matlab answers. This can be done in a rather straightforward way. Please read the "Getting started" part of the documentation and ask specific questions whenever you encounter problems. People will be happy to help you then.
採用された回答
Sean de Wolski
2013 年 2 月 20 日
Use a nested for loop:
for ii = 1:n
for jj = ii:n
stuff
end
end
0 件のコメント
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!