フィルターのクリア

How can generalize several "For loop" ?

2 ビュー (過去 30 日間)
STamer
STamer 2013 年 2 月 20 日
Hello;
I want to generalize the expression.It goes "for i=5:n"......"for i=n:n".
I tried nested loop statement but couldn't manage..Is there any help? Thanks and regards
A=input('Enter nxn matrix:')
B=input('Enter solution matrix(n*1):')
[n n]=size(A);
L=zeros(n);
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

採用された回答

Babak
Babak 2013 年 2 月 20 日
A=input('Enter nxn matrix:')
B=input('Enter solution matrix(n*1):')
[n n]=size(A);
L=zeros(n);
for i=1:n
L(i,i)=1;
end
for k = 1:n
for i=k+1:n
L(i,k)= A(i,k)/A(k,k);
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRead, Write, and Modify Image についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by