Error in sum of matrixes
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear Community,
I need to create a script where I obtain a matrix as an output. In addition, such matrix is a resultant matrix of the sum of 8 other matrixes. Unfortunately when I create the for loop it saves only the 8th matrix in the variable that I created to fulfill such requirement. Could you pelase help me?
clc
close all
clear all
m = 5;
Z = randi(20,1,10);
n = size(Z,2);
Z_out = [Z;zeros(m-1,n)];
for ii=2:m
Z_out(ii,:) = Z_out(ii-1,:) + randi(5,1,n);
end
%% Copiando el sistema
Nplies = 8;
thetadt = [90; -45; 45; 0; 0; 45; -45; 90];
t = 0.125; %SI unit, milimeters
h = Nplies*t;
% Ply engineering properties (UD-Laminat)
E1 = 240000; % N/mm^2
nu12 = .3133 ;
E2 = 7500 ; % N/mm^2
G12 = 5150 ; % N/mm^2
nu21 = .3133 ; %nu12 * E2 / E1
a1 = -0.38e-7 ; % coefficients of thermal expansion [1/°C]
a2 = 1e-5 ;
deltaT = 0;
% Q matrix (material coordinates)- reduced stiffness matrix
denom = 1 - nu12 * nu21 ;
Q11 = E1 / denom ; %reduced stiffness coefficients
Q12 = nu12 * E1 / denom ;
Q21 = nu12 * E2 / denom ;%reduced stiffness coefficients
Q22 = E2 / denom ; %reduced stiffness coefficients
Q66 = G12 ; %reduced stiffness coefficients
m = 3;
Ai = [1,0,0;0,1,0;0,0,1];
Aii = zeros(3,3);
Qbari = zeros(3,3);
R = [1,0,0;0,1,0;0,0,2];
Q = [ E1/denom nu12*E1/denom 0; nu12* E2/denom E2/denom 0; 0 0 G12]; %Reduced stiffness matrix
AA=[];
for i = 1:Nplies
theta = thetadt(i) * pi / 180;% ply i angle in radians, from bottom
c = cos(theta);
s = sin(theta);
T = [ c^2 s^2 -2*c*s; s^2 c^2 2*c*s; c*s -c*s (c^2 - s^2)];
T_inv = [c^2 s^2 c*s; s^2 c^2 -c*s; -2*c*s 2*c*s (c^2 - s^2)];
Qbar = Qbari + T * Q * T_inv %transformed reduced stiffness matrix
A{i,1,1} = Aii + Qbar*t
end
Af = A{1,1,1} + A{2,1,1} + A{3,1,1} + A{4,1,1} + A{5,1,1} + A{6,1,1} + A{7,1,1} + A{8,1,1}
%% another approach
res=0;
for k=1:5
M=rand(4);
res=bsxfun(@plus,res,M);
end
%%
%if ii<2
% A=0;
% else
%transformed reduced stiffness matrix
% A = Aii + Qbar*(ii-1)*t
% end
4 commentaires
Image Analyst
le 14 Juil 2020
Did you try the answer below? And why didn't you format your code like I suggested?
Réponses (1)
Rafael Hernandez-Walls
le 14 Juil 2020
try this
Nplies = 8;
thetadt = [90; -45; 45; 0; 0; 45; -45; 90];
t = 0.125; %SI unit, milimeters
h = Nplies*t;
% Ply engineering properties (UD-Laminat)
E1 = 240000; % N/mm^2
nu12 = .3133 ;
E2 = 7500 ; % N/mm^2
G12 = 5150 ; % N/mm^2
nu21 = .3133 ; %nu12 * E2 / E1
a1 = -0.38e-7 ; % coefficients of thermal expansion [1/°C]
a2 = 1e-5 ;
deltaT = 0;
% Q matrix (material coordinates)- reduced stiffness matrix
denom = 1 - nu12 * nu21 ;
Q11 = E1 / denom ; %reduced stiffness coefficients
Q12 = nu12 * E1 / denom ;
Q21 = nu12 * E2 / denom ;%reduced stiffness coefficients
Q22 = E2 / denom ; %reduced stiffness coefficients
Q66 = G12 ; %reduced stiffness coefficients
m = 3;
Ai = [1,0,0;0,1,0;0,0,1];
Aii = zeros(3,3);
R = [1,0,0;0,1,0;0,0,2];
Q = [ E1/denom nu12*E1/denom 0; nu12* E2/denom E2/denom 0; 0 0 G12]; %Reduced stiffness matrix
AA=[];
for i = 1:Nplies
theta = thetadt(i) * pi / 180;% ply i angle in radians, from bottom
c = cos(theta)
s = sin(theta)
T = [ c^2 s^2 -2*c*s; s^2 c^2 2*c*s; c*s -c*s (c^2 - s^2)]
T_inv = [c^2 s^2 c*s; s^2 c^2 -c*s; -2*c*s 2*c*s (c^2 - s^2)]
Qbar = T * Q * T_inv;
for ii=2
%transformed reduced stiffness matrix
A = Aii + Qbar*(ii-1)*t;
AA = [AA; sum(A,1)]
end
end
Voir également
Catégories
En savoir plus sur Spline Postprocessing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!