Matrix with for cycle

2 ビュー (過去 30 日間)
Carlos Betancur
Carlos Betancur 2020 年 10 月 6 日
コメント済み: Carlos Betancur 2020 年 10 月 6 日
Hello I want to create an i number of matrix with the arrangement that Qbar shows, but it generates a dimension error, what can I do?
for i=1:N
a(i) = input('Direction [deg]: ');
theta_deg = a(i);
theta_rad = theta_deg*pi/180;
Qbar_11(i) = Q_11*((cos(theta_rad))^4)+2*(Q_12+2*Q_66)*((sin(theta_rad))^2)*((cos(theta_rad))^2)+Q_22*((sin(theta_rad))^4);
Qbar_12(i) = (Q_11+Q_22-4*Q_66)*((sin(theta_rad))^2)*((cos(theta_rad))^2)+Q_12*(((sin(theta_rad))^4)+((cos(theta_rad))^4));
Qbar_22(i)= Q_11*((sin(theta_rad))^4)+2*(Q_12+2*Q_66)*((sin(theta_rad))^2)*((cos(theta_rad))^2)+Q_22*((cos(theta_rad))^4);
Qbar_16(i) = (Q_11-Q_12-2*Q_66)*(sin(theta_rad))*((cos(theta_rad))^3)+(Q_12-Q_22+2*Q_66)*((sin(theta_rad))^3)*(cos(theta_rad));
Qbar_26(i) = (Q_11-Q_12-2*Q_66)*((sin(theta_rad))^3)*(cos(theta_rad))+(Q_12-Q_22+2*Q_66)*(sin(theta_rad))*((cos(theta_rad))^3);
Qbar_66(i) = (Q_11+Q_22-2*Q_12-2*Q_66)*((sin(theta_rad))^2)*((cos(theta_rad))^2)+Q_66*(((sin(theta_rad))^4)+((cos(theta_rad))^4));
Qbar(i) = [Qbar_11(i),Qbar_12(i),Qbar_16(i);Qbar_12(i),Qbar_22(i),Qbar_26(i);Qbar_16(i),Qbar_26(i),Qbar_66(i)]
end
the error is ꃭ؀error: Codigo_V4: =: nonconformant arguments (op1 is 1x1, op2 is 3x3)

採用された回答

madhan ravi
madhan ravi 2020 年 10 月 6 日
Qbar = cell(N, 1); % preallocate properly for other variables also
Qbar{ii} = ... inside loop
  5 件のコメント
madhan ravi
madhan ravi 2020 年 10 月 6 日
If you copied my code correctly, it’s highly unlikely to get that error message.
Carlos Betancur
Carlos Betancur 2020 年 10 月 6 日
Thanks !

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by