make matrix by using vectors created by loop

2 ビュー (過去 30 日間)
sujit
sujit 2013 年 7 月 7 日
%I want to make matrix by all vectors of x for all values of r in following code
%save it to 'Matrics'
b =[2,3,5]';
for r = -1:0.1:1
A =[5,(2*r),r ;
3,6 ,(2*r-1);
2,(r-1),3*r ];
x = b\A;
%Matrics = ????
end

採用された回答

Walter Roberson
Walter Roberson 2013 年 7 月 7 日
allX = [];
[...]
allX = [allX; x];
  1 件のコメント
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019 年 5 月 18 日
This is not a complete answer!

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

その他の回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019 年 5 月 18 日
Hi,
% Here is the complete solution that saves all computed roots of the linear system w.r.t. r(ii)
b =[2,3,5]';r = -1:0.1:1;
for ii=1:numel(r)
A =[5,(2*r(ii)),r(ii) ;
3,6 ,(2*r(ii)-1);
2,(r(ii)-1),3*r(ii) ];
x = b\A;
Matrics(ii,:) = x;
end
Good luck.

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by