make matrix by using vectors created by loop

12 visualizaciones (últimos 30 días)
sujit
sujit el 7 de Jul. de 2013
Comentada: Sulaymon Eshkabilov el 18 de Mayo de 2019
%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

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Jul. de 2013
allX = [];
[...]
allX = [allX; x];

Más respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 18 de Mayo de 2019
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.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by