Code is working:: However, Matrix obtained not correct (Code is working but the zeros elements place are not correct

1 view (last 30 days)
Mark Sc
Mark Sc on 1 Mar 2021
Edited: Cris LaPierre on 3 Mar 2021
Hi all,
I need help in this code,
The Matrix obtained is correct however, the zeros elements are not in the correct place
Should be the following:
[164 54 0;
54 109 0;
0 0 109] ;
I think something is wrong in the indexing, but can not find ??
Below are the code:
clearvars;
clc;
close all;
E11 = 54;
E22 = 54;
v12 = .25;
v23 = .25;
S = zeros(9,9);
S(1,1) = 1/E11;
S(1,2) = -v12/E11;
S(1,3) = S(1,2);
S(2,1) = S(1,2);
S(2,2) = 1/E22;
S(2,3) = -v23/E22;
S(3,1) = S(1,2);
S(3,2) = S(2,3);
S(3,3) = 1/E22;
S(4,4) = (1+v12)/(E11);
S(5,5) = S(4,4);
S(6,6) = S(5,5);
S(7,7) = S(4,4);
S(8,8) = S(5,5);
S(9,9) = S(6,6);
C_n = inv(S);
C(1:3,1:3,1:3,1:3) = zeros(3,3,3,3);
IND =[1 1; 2 2; 3 3; 1 2; 2 3; 3 1; 2 1; 3 2; 1 3]
for m=1:9
for n=1:9
C(IND(m,1),IND(m,2),IND(n,1),IND(n,2)) = C_n(m,n);
end
end
t = 2.54;
delta = [1 1 1]*t;
A = zeros(3,3); % INITALIZATION OF A MATRIX
delAJ = [1 0 0]*(t*t);%permut(j,m,n)*delta(m)*delta(n);
for i = 1:3
for k = 1:3
for j = 1:3
for l = 1:3
A(i,k) = A(i,k) + delAJ(j)/delta(l)*C(i,j,k,l);
end
end
end
end
A
  10 Comments
Mark Sc
Mark Sc on 3 Mar 2021
Thanks for your reply..
I totally understand what point of view,
Next time, I will try to explain or comment what am I doing
Thanks again

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by