Help with if statements
Show older comments
Hello I am getting errors for a varaible I am defining in a if loop any help would be great.
The error is stopping it at no QbarA Variable defined
close all, clear all,clc
E1 = 40;
E2 = 1.8;
V12 = 0.25;
V21 = 0.01125;
G12 = 0.7;
t = 0.005;
z0 = -t*2;
z1 = -t;
z2 = 0;
z3 = t;
z4 = t*2;
theta = [0,15,90,-30];
Q11 = E1/(1-V12*V21);
Q12 = (V21*E2)/(1-V12*V21);
Q22 = E2/(1-V12*V21);
Q66 = G12;
for i = 1:4
m = cosd(theta(i));
n = sind(theta(i));
end
Qbar11 = Q11.*m^4+2.*(Q12+2*Q66).*m^2.*n^2+Q22*n^4;
Qbar12 = (Q11+Q22-4*Q66)*m^2*n^2+Q12*(m^4+n^4);
Qbar16 = (Q11-Q12-2*Q66)*m^3*n+(Q12-Q22+2*Q66)*m*n^3;
Qbar22 = Q11.*n^4+2.*(Q12+2*Q66).*m^2.*n^2+Q22*m^4;
Qbar26 = (Q11-Q12-2*Q66)*m*n^3+(Q12-Q22+2*Q66)*m^3*n;
Qbar66 = (Q11+Q22-2*Q12-2*Q66)*m^2*n^2+Q66*(m^4+n^4);
Qbar = [Qbar11 Qbar12 Qbar16
Qbar12 Qbar22 Qbar26
Qbar16 Qbar26 Qbar66]
if i == 1
QbarA = Qbar;
end
if i == 2
QbarB = Qbar;
end
if i == 3
QbarC = Qbar;
end
if i == 4
QbarD = Qbar;
end
A = QbarA*t+QbarB*t+QbarC*t+QbarD*t
B = 1/2*(QbarA*(z1^2-z0^2)+QbarB*(z2^2-z1^2)+QbarC*(z3^2-z2^2)+QbarD*(z4^2-z3^2))
D = 1/3*(QbarA*(z1^3-z0^3)+QbarB*(z2^3-z1^3)+QbarC*(z3^3-z2^3)+QbarD*(z4^3-z3^3))
Nx = 1200*4*t;
Ny = -600*4*t;
Nxy = 600*4*t;
My = 36/12;
Mx = -18/18;
Mxy = 0;
N = [Nx;Ny;Nxy]
M = [Mx;My;Mxy]
Output = [A,B;B,D]^-1*[N,M]
Accepted Answer
More Answers (0)
Categories
Find more on BeagleBone Black in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!