How do I put my row vector answers into a matrix?
이전 댓글 표시
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
채택된 답변
추가 답변 (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.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!