How do I put my row vector answers into a matrix?
Ältere Kommentare anzeigen
I am wondering how I get my answers (x') which is a row vector into a matrix with 26 rows and 3 columns.
MATLAB CODE
V2=0;
V3=50;
W=zeros(26,3);
for V1=50:2:100;
b=[V1; V2; V3]
ans3=P*b;
y=L\ans3;
x=U\y;
x'
end
I want the final result to look something like this: W=[a1 b1 c1; a2 b2 c3; a3 b3 c3......a26 b26 c26] How do I get each of vectors into a matrix? Thank you for your help, Maddy
Akzeptierte Antwort
Weitere Antworten (1)
If the rest of the computations is correct (P, L, U have appropriate dimensions), you would do something like
W(..., :) = x.' ;
with the ... a row index that you don't compute presently. You could build one the following way:
...
V1 = 50:2:100 ;
for ii = 1 : numel(V1)
b = [V1(ii); V2; V3] ;
...
W(ii,:) = x.' ;
end
There would be a more appropriate (vector) way for doing this computation I suspect, but let's first solve the issue of addressing rows of W.
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!