For loop to matrix

3 ビュー (過去 30 日間)
Nicolas Mavriplis
Nicolas Mavriplis 2016 年 1 月 15 日
コメント済み: Mohammad Abouali 2016 年 1 月 15 日
Hello, I have a for loop here for a LU decomposition and I am trying to append my answers into a matrix. Any help here?
This is what I have.
V2= 0;
V3= 50;
for V1=49:2:99;
b=[V1; V2; V3];
y=L\b;
x=U\y
end
I get the answer to x each time but separate to the one before it. How do I append all of the answers into a 3x26 matrix? Thanks for the help

採用された回答

Mohammad Abouali
Mohammad Abouali 2016 年 1 月 15 日
編集済み: Mohammad Abouali 2016 年 1 月 15 日
Don't need a for loop. Do it like this:
V1=49:2:99;
V2=zeros(1,numel(V1));
V3=50*ones(1,numel(V1));
b=[V1;V2;V3];
y=L\b;
x=U\y;
Then each answer is stored as a separate column of x.
  2 件のコメント
Nicolas Mavriplis
Nicolas Mavriplis 2016 年 1 月 15 日
Great thank you so much!
Mohammad Abouali
Mohammad Abouali 2016 年 1 月 15 日
you are welcome

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by