Translating vector into locations in a matrix
이전 댓글 표시
I'm attempting to set up an n row by 4 column matrix using data from column vectors Z1, Z2, & Z3. The problem is I need to place the random values from these column vectors into random locations in the n row by 4 column matrix. How can I specifically put certain values from the column vectors into certain locations in the K matrix? I know the K matrix will be always 4 columns wide, but could be any length. The rows of the K matrix will repeat every 4 utilizing a different value from one of the Z1, Z2, & Z3 column vectors. (I'm trying to come up with a local stiffness matrix that I can later transform into a global stiffness matrix). In the following code I'm attempting to set up a structure where the every 4th row in column 1 of Matrix K is row 1 - Z2(1,1), row 5 - Z2(5,1), row 9 - Z2(9,1), and so on. Any help would be appreciated.
K = zeros(4*member_count,4);
for r = 1:4:4*member_count;
for i = 1:Z2_count;
s(i,r) = Z2(i,1);
for j = 1:r
K(j,1) = s(i,r)
end
end
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!