How to recall values from for loop into a column matrix?

조회 수: 1 (최근 30일)
Robert  Flores
Robert Flores 2018년 10월 14일
댓글: madhan ravi 2018년 10월 14일
Hello everyone,
I am trying to get four values from the for loop statement I made, Q_bar1, Q_bar2, and so forth. But, I don't know how to assign those values into a column matrix. Below is a copy of my code, if anyone is able to help, it will be most appreciated.
CODE:
E1 = 27.1; % measured in Msi
E2 = 1.3; % measured in Msi
E3 = E2;
v12 = 0.33;
v21 = E2*(v12/E1);
v13 = v12;
v31 = E3*(v13/E1);
G12 = 0.80; % measured in Msi
G13 = G12;
v23 = 0.5;
v32 = E3*(v23/E2);
delta = (1-(v12*v21)-(v23*v32)-(v13*v31)-2*(v21*v32*v13))/(E1*E2*E3);
C11 = (1-(v23*v32))/(E2*E3*delta);
C22 = (1-(v13*v31))/(E1*E3*delta);
C33 = (1-(v12*v21))/(E1*E2*delta);
C12 = (v12+(v13*v32))/(E1*E3*delta);
C23 = (v23+(v21*v13))/(E1*E2*delta);
C13 = (v31+(v21*v32))/(E2*E3*delta);
C55 = G13;
C66 = G12;
% Stiffness Matrix
C = [C11 C12 C12 0 0 0;
C12 C22 C23 0 0 0;
C12 C23 C22 0 0 0;
0 0 0 (C22-C23)/2 0 0;
0 0 0 0 C55 0;
0 0 0 0 0 C55]
% Reduced Stiffness Matrix
Q11 = C11-(C12^2/C22);
Q12 = C12-(C23/C22);
Q21 = Q12;
Q22 = C22-(C23^2/C22);
Q55 = C55;
Q66 = C66;
Q = [Q11 Q12 0;
Q21 Q22 0;
0 0 Q55]
% Transformed Reduced Stiffness Matrix
% theta = input('insert desired angle= ')
for theta = [0 17 -63 90]
m = cosd(theta);
n = sind(theta);
Qxx = m^4*Q11 + n^4*Q22 + 2*m^2*n^2*Q12 + 4*m^2*n^2*Q66;
Qxy = m^2*n^2*Q11 + m^2*n^2*Q22 + (m^4+n^4)*Q12 - 4*m^2*n^2*Q66;
Qxs = m^3*n*Q11 - m*n^3*Q22 - m*n*(m^2-n^2)*Q12 - 2*m*n*(m^2-n^2)*Q66;
Qyx = Qxy;
Qyy = n^4*Q11 + m^4*Q22 + 2*m^2*n^2*Q12 + 4*m^2*n^2*Q66;
Qys = m*n^3*Q11 - m^3*n*Q22 + m*n*(m^2-n^2)*Q12 + 2*m*n*(m^2-n^2)*Q66;
Qss = m^2*n^2*Q11 + m^2*n^2*Q22 - 2*m^2*n^2*Q12 + (m^2-n^2)^2*Q66;
Qsx = Qxs;
Qsy = Qys;
Q_bar = [Qxx Qxy Qxs;
Qyx Qyy Qys;
Qsx Qsy Qss]
end

채택된 답변

madhan ravi
madhan ravi 2018년 10월 14일
E1 = 27.1; % measured in Msi
E2 = 1.3; % measured in Msi
E3 = E2;
v12 = 0.33;
v21 = E2*(v12/E1);
v13 = v12;
v31 = E3*(v13/E1);
G12 = 0.80; % measured in Msi
G13 = G12;
v23 = 0.5;
v32 = E3*(v23/E2);
delta = (1-(v12*v21)-(v23*v32)-(v13*v31)-2*(v21*v32*v13))/(E1*E2*E3);
C11 = (1-(v23*v32))/(E2*E3*delta);
C22 = (1-(v13*v31))/(E1*E3*delta);
C33 = (1-(v12*v21))/(E1*E2*delta);
C12 = (v12+(v13*v32))/(E1*E3*delta);
C23 = (v23+(v21*v13))/(E1*E2*delta);
C13 = (v31+(v21*v32))/(E2*E3*delta);
C55 = G13;
C66 = G12;
% Stiffness Matrix
C = [C11 C12 C12 0 0 0;
C12 C22 C23 0 0 0;
C12 C23 C22 0 0 0;
0 0 0 (C22-C23)/2 0 0;
0 0 0 0 C55 0;
0 0 0 0 0 C55]
% Reduced Stiffness Matrix
Q11 = C11-(C12^2/C22);
Q12 = C12-(C23/C22);
Q21 = Q12;
Q22 = C22-(C23^2/C22);
Q55 = C55;
Q66 = C66;
Q = [Q11 Q12 0;
Q21 Q22 0;
0 0 Q55]
% Transformed Reduced Stiffness Matrix
% theta = input('insert desired angle= ')
ctr=1
for theta = [0 17 -63 90]
m = cosd(theta);
n = sind(theta);
Qxx = m^4*Q11 + n^4*Q22 + 2*m^2*n^2*Q12 + 4*m^2*n^2*Q66;
Qxy = m^2*n^2*Q11 + m^2*n^2*Q22 + (m^4+n^4)*Q12 - 4*m^2*n^2*Q66;
Qxs = m^3*n*Q11 - m*n^3*Q22 - m*n*(m^2-n^2)*Q12 - 2*m*n*(m^2-n^2)*Q66;
Qyx = Qxy;
Qyy = n^4*Q11 + m^4*Q22 + 2*m^2*n^2*Q12 + 4*m^2*n^2*Q66;
Qys = m*n^3*Q11 - m^3*n*Q22 + m*n*(m^2-n^2)*Q12 + 2*m*n*(m^2-n^2)*Q66;
Qss = m^2*n^2*Q11 + m^2*n^2*Q22 - 2*m^2*n^2*Q12 + (m^2-n^2)^2*Q66;
Qsx = Qxs;
Qsy = Qys;
Q_bar(:,:,ctr) = [Qxx Qxy Qxs;
Qyx Qyy Qys;
Qsx Qsy Qss]
ctr=ctr+1;
end
  댓글 수: 1
madhan ravi
madhan ravi 2018년 10월 14일
Make sure to accept the answer and give a vote if it works

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by