MATLAB Answers

sujit
0

make matrix by using vectors created by loop

Asked by sujit
on 7 Jul 2013
Latest activity Commented on by Sulaymon Eshkabilov on 18 May 2019 at 5:12
%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

  0 Comments

Sign in to comment.

2 Answers

Answer by Walter Roberson
on 7 Jul 2013
 Accepted Answer

allX = [];
[...]
allX = [allX; x];

  1 Comment

This is not a complete answer!

Sign in to comment.


Answer by Sulaymon Eshkabilov on 18 May 2019 at 4:57

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.

  0 Comments

Sign in to comment.