Using 3x3 matrix to create 21x21 matrix

조회 수: 3 (최근 30일)
Maria Galle
Maria Galle 2019년 11월 11일
댓글: Maria Galle 2019년 11월 11일
I have built a 3x3 matrix using the code below
EA = 1;
h = 1;
F = @(xi)(xi-0.5).*(xi-0.5)
k(1,1) =EA/h* 2*quad(F, -1, 1)
F = @(xi)(xi-0.5).*(-2*xi)
k(1,2) = EA/h* 2*quad(F, -1, 1)
F = @(xi)(xi-0.5).*(xi+0.5)
k(1,3) = EA/h* 2*quad(F, -1, 1)
F = @(xi)(-2*xi).*(-2*xi)
k(2,2) =EA/h* 2*quad(F, -1, 1)
F = @(xi)(xi+0.5).*(-2*xi)
k(2,3) = EA/h*2*quad(F, -1, 1)
F = @(xi)(xi+0.5).*(xi+0.5)
k(3,3) = EA/h*2*quad(F, -1, 1)
k(2,1) = k(1,2)
k(3,1) = k(1,3)
k(3,2) = k(2,3)
I want to use the 3x3 matrix above to create a 21x21 matrix following the pattern below
new doc 2019-11-11 00.20.06_1.jpg
the overlapped elements should be added together, the numbers not in the 3x3 matrix are zero in the bigger matrix...k(4,1)=0 etc..
10 3x3 matrices should be used
I want to use a for loop unless there's another method
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 11월 11일
It is a lot easier and clearer to loop building up the matrix, at least in the case where the different matrices on the diagonal are different.

댓글을 달려면 로그인하십시오.

채택된 답변

Erivelton Gualter
Erivelton Gualter 2019년 11월 11일
It is not clear the overlap values. I assumed the following:
  1. k33+k11
  2. k33+k12
  3. K33+k13
  4. K33+k23
  5. ..., Until the last is k33+k33
The other values is just copy from the given location. Then, you might use only for loop for this. Check in the following:
k19 = reshape(k(1:3,1:3),1,9); % Reshape for [k11 k12 k12 k21 k22 k23 k31 k32 k33]
j = 1;
for i=4:2:21
k(i,i-1) = k(2,1);
k(i-1,i) = k(2,1);
k(i+1,i-1) = k(3,1);
k(i-1,i+1) = k(3,1);
k(i+1,i) = k(3,2);
k(i,i+1) = k(3,2);
k(i,i) = k(2,2);
k(i+1,i+1) = k(3,3) + k19(j); % Overlap goes here
j = j + 1;
end
  댓글 수: 3
Erivelton Gualter
Erivelton Gualter 2019년 11월 11일
Can you rephrase what is the values for k(3,3), k(5,5), k(7,7), ...
Maria Galle
Maria Galle 2019년 11월 11일
k(3,3)=k(3,3)+k(1,1)
EA = 1;
h = 1;
F = @(xi)(xi+0.5).*(xi+0.5)
k(3,3) = EA/h*2*quad(F, -1, 1)
F = @(xi)(xi-0.5).*(xi-0.5)
k(1,1) =EA/h* 2*quad(F, -1, 1)
this equals k(5,5) and k(7,7)...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by