the matrix addition should come 0 but it is not happening
i am adding a matrix in for loop
Dtb=zeros(3,3);
Dtrb=Dtb;
Drrb=Dtb;
Dts=zeros(2,2);
for N=1:nlayer
h1=-h/2+(N-1)*th;
h2=h1+th;
ah1=h2-h1;
bh1=(h2^2-h1^2)/2;
ch1=(h2^3-h1^3)/3;
% ———–
if(N <= nlayer/2 || N == 1)
theta=(1+(-1)^N)*pi/4;
else
theta = -1*(-1+(-1)^N)*pi/4;
end
% ————–
theta = rad2deg( theta );
t1=(cosd(theta))^4;
t2=(sind(theta))^4;
t3=(sind(theta)*cosd(theta))^2;
t4=sind(theta)*(cosd(theta))^3;
t5=cosd(theta)*(sind(theta))^3;
%**********************************************************
c111=c11*t1 + 2*(c12+2*c66)*t3 + c22*t2;
c121=(c11 + c22 – 4*c66)*t3 + c12*(t1+t2);
c221=c11*t2 + 2*(c12+2*c66)*t3 + c22*t1;
c161=(c11-c12-2*c66)*t4 + (c12-c22+2*c66)*t5;
c261=(c11-c12-2*c66)*t5 + (c12-c22+2*c66)*t4;
c661=(c11+c22-2*c12-2*c66)*t3 + c66*(t1+t2);
c441=c44*(cos(theta))^2 + c55*(sin(theta))^2;
c451=(c55-c44)*cos(theta)*sin(theta);
c551=c55*(cos(theta))^2 + c44*(sin(theta))^2;
Cb=[c111 c121 c161; c121 c221 c261; c161 c261 c661];
Cs=[c551 c451;c451 c441];
Dtrb = Dtrb + bh1*Cb;
end
but the resulting Dtrb atrix is not coming 0,
as you can see from fig: matrix for iteration 10 is bh1*Cb matrix which is added to Dtrb matrix and in figure both are same but opp in sign so if we add it should come 0 but as you can see in fig the result is not 0 but it is something * e-11 comingi am adding a matrix in for loop
Dtb=zeros(3,3);
Dtrb=Dtb;
Drrb=Dtb;
Dts=zeros(2,2);
for N=1:nlayer
h1=-h/2+(N-1)*th;
h2=h1+th;
ah1=h2-h1;
bh1=(h2^2-h1^2)/2;
ch1=(h2^3-h1^3)/3;
% ———–
if(N <= nlayer/2 || N == 1)
theta=(1+(-1)^N)*pi/4;
else
theta = -1*(-1+(-1)^N)*pi/4;
end
% ————–
theta = rad2deg( theta );
t1=(cosd(theta))^4;
t2=(sind(theta))^4;
t3=(sind(theta)*cosd(theta))^2;
t4=sind(theta)*(cosd(theta))^3;
t5=cosd(theta)*(sind(theta))^3;
%**********************************************************
c111=c11*t1 + 2*(c12+2*c66)*t3 + c22*t2;
c121=(c11 + c22 – 4*c66)*t3 + c12*(t1+t2);
c221=c11*t2 + 2*(c12+2*c66)*t3 + c22*t1;
c161=(c11-c12-2*c66)*t4 + (c12-c22+2*c66)*t5;
c261=(c11-c12-2*c66)*t5 + (c12-c22+2*c66)*t4;
c661=(c11+c22-2*c12-2*c66)*t3 + c66*(t1+t2);
c441=c44*(cos(theta))^2 + c55*(sin(theta))^2;
c451=(c55-c44)*cos(theta)*sin(theta);
c551=c55*(cos(theta))^2 + c44*(sin(theta))^2;
Cb=[c111 c121 c161; c121 c221 c261; c161 c261 c661];
Cs=[c551 c451;c451 c441];
Dtrb = Dtrb + bh1*Cb;
end
but the resulting Dtrb atrix is not coming 0,
as you can see from fig: matrix for iteration 10 is bh1*Cb matrix which is added to Dtrb matrix and in figure both are same but opp in sign so if we add it should come 0 but as you can see in fig the result is not 0 but it is something * e-11 coming i am adding a matrix in for loop
Dtb=zeros(3,3);
Dtrb=Dtb;
Drrb=Dtb;
Dts=zeros(2,2);
for N=1:nlayer
h1=-h/2+(N-1)*th;
h2=h1+th;
ah1=h2-h1;
bh1=(h2^2-h1^2)/2;
ch1=(h2^3-h1^3)/3;
% ———–
if(N <= nlayer/2 || N == 1)
theta=(1+(-1)^N)*pi/4;
else
theta = -1*(-1+(-1)^N)*pi/4;
end
% ————–
theta = rad2deg( theta );
t1=(cosd(theta))^4;
t2=(sind(theta))^4;
t3=(sind(theta)*cosd(theta))^2;
t4=sind(theta)*(cosd(theta))^3;
t5=cosd(theta)*(sind(theta))^3;
%**********************************************************
c111=c11*t1 + 2*(c12+2*c66)*t3 + c22*t2;
c121=(c11 + c22 – 4*c66)*t3 + c12*(t1+t2);
c221=c11*t2 + 2*(c12+2*c66)*t3 + c22*t1;
c161=(c11-c12-2*c66)*t4 + (c12-c22+2*c66)*t5;
c261=(c11-c12-2*c66)*t5 + (c12-c22+2*c66)*t4;
c661=(c11+c22-2*c12-2*c66)*t3 + c66*(t1+t2);
c441=c44*(cos(theta))^2 + c55*(sin(theta))^2;
c451=(c55-c44)*cos(theta)*sin(theta);
c551=c55*(cos(theta))^2 + c44*(sin(theta))^2;
Cb=[c111 c121 c161; c121 c221 c261; c161 c261 c661];
Cs=[c551 c451;c451 c441];
Dtrb = Dtrb + bh1*Cb;
end
but the resulting Dtrb atrix is not coming 0,
as you can see from fig: matrix for iteration 10 is bh1*Cb matrix which is added to Dtrb matrix and in figure both are same but opp in sign so if we add it should come 0 but as you can see in fig the result is not 0 but it is something * e-11 coming matrix addition bug MATLAB Answers — New Questions