Unexpected MATLAB expression.

1 Ansicht (letzte 30 Tage)
lgdupont
lgdupont am 10 Feb. 2019
Kommentiert: lgdupont am 10 Feb. 2019
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 10 Feb. 2019
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.
  2 Kommentare
lgdupont
lgdupont am 10 Feb. 2019
Ah yes, I see that now! I was looking for missing brackets on the second line. Thanks!
lgdupont
lgdupont am 10 Feb. 2019
That fixed everything actually! Thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by