Unexpected MATLAB expression.
1 次查看(过去 30 天)
显示 更早的评论
Everything works until the while loop. The Sbar matrix is where I have issues. The first line works. On the second line at the first 'S12' I get an error "Invalid syntax at 'S12'. Possibly, a ), }, or ] is missing." The fifth line has an error on the first 'S11' saying "Parse error at S11: usage might be invalid MATLAB syntax." On the eighth line on the first '(' I get the error "Parse error at '(': usage might be invalid MATLAB syntax."
If anyone can help me as to why I'm getting these errors, it would be much appreciated! I tried not splitting the lines and I still get the same errors.
My code:
E11 = 100E9;
E22 = 18E9;
nu12 = 0.33;
G12 = 10E9;
S = [1/E11 -nu12/E11 0; -nu12/E11 1/E22 0; 0 0 1/G12];
Q = [E11^2/(E11-nu12^2*E22) nu12*E11*E22/(E11-nu12^2*E22) 0; nu12*E11*E22/(E11-nu12^2*E22) ...
E11*E22/(E11-nu12^2*E22) 0; 0 0 G12];
S11 = S(1,1);
S12 = S(1,2);
S22 = S(2,2);
S33 = S(3,3);
theta = 0;
while theta <= pi/2
Sbar = [S11*cos(theta)^4+(2*S12+S33*cos(theta)^2*sin(theta)^2+S22*sin(theta)^4 ...
S12*(cos(theta)^4+sin(theta)^4)+(S11+S22-S33)*cos(theta)^2*sin(theta)^2 ...
(2*S11-2*S12-S33)*cos(theta)^3*sin(theta)-(2*S22-2*S12-S33)*cos(theta)*sin(theta)^3; ...
S12*(cos(theta)^4+sin(theta)^4)+(S11+S22-S33)*cos(theta)^2*sin(theta)^2 ...
S11*sin(theta)^4+(2*S12+S33)*cos(theta)^2*sin(theta)^2+S22*cos(theta)^4 ...
(2*S11-2*S12-S33)*cos(theta)*sin(theta)^3-(2*S22-2*S12-S33)*cos(theta)^3*sin(theta); ...
(2*S11-2*S12-S33)*cos(theta)^3*sin(theta)-(2*S22-2*S12-S33)*cos(theta)*sin(theta)^3 ...
(2*S11-2*S12-S33)*cos(theta)*sin(theta)^3-(2*S22-2*S12-S33)*cos(theta)^3*sin(theta) ...
2*(2*S11+2*S22-4*S12-S33)*cos(theta)^2*sin(theta)^2+S33*cos(theta)^4*sin(theta)^4];
Exx_eff = 1/Sbar(1,1);
Eyy_eff = 1/Sbar(2,2);
nu12_eff = -Sbar(1,2)/Sbar(1,1);
nu21_eff = -Sbar(1,2)/Sbar(2,2);
Gxy_eff = 1/Sbar(3,3);
etaxx,xy_eff = Sbar(1,3)/Sbar(1,1);
etayy,xy_eff = Sbar(2,3)/Sbar(2,2);
etaxy,xx_eff = Sbar(1,3)/Sbar(3,3);
etaxy,yy_eff = Sbar(2,3)/Sbar(3,3);
plot(theta,Exx_eff,Eyy_eff)
end
0 个评论
采纳的回答
Walter Roberson
2019-2-10
Count your brackets on the first line of that definition. You are missing a ) on that first line.
Start your count at 0; increase every time you encounter a ( or [ or { and decrease every time you encounter a } or ] or ) . You will find that at the end of the line the count is 1, indicating 1 too many open brackets compared to close brackets.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!