When i run the blow code, the loop gets stuck on the underline line and it says that the indices on the left are not compatible with the indices on the right.

1 回表示 (過去 30 日間)
clc
clear all
sigma1=0.002;
sigma2=-0.003;
tau_12=0.004;
E1=181;
E2=10.3;
mu_12=0.28;
G12=7.17;
tetha=1:90;
for i=1:90
c(i)=cosd(tetha(i));
s(i)=sind(tetha(i));
Stress_12=[sigma1; sigma2; tau_12];
%S matrix calculation
S=[1/E1 -mu_12/E1 0;-mu_12/E1 1/E2 0;0 0 1/G12];
%Q matrix calculation
Q=inv(S);
%Strain Vector calculation
Strain_12=S*Stress_12;
%Transformation matrix calculation
T(i)=[c(i).^2 s(i).^2 2.*s(i).*c(i); s(i).^2 c(i).^2 -2.*s(i).*c(i); -s(i).*c(i) s(i).*c(i) (c(i).^2)-(s(i).^2)];
%Inverse of the transformation matrix
T_1(i)=inv(T(i));
end

回答 (2 件)

KSSV
KSSV 2022 年 3 月 28 日
clc
clear all
sigma1=0.002;
sigma2=-0.003;
tau_12=0.004;
E1=181;
E2=10.3;
mu_12=0.28;
G12=7.17;
tetha=1:90;
c=cosd(tetha);
s=sind(tetha);
T = zeros(3,3,90) ;
for i=1:90
Stress_12=[sigma1; sigma2; tau_12];
%S matrix calculation
S=[1/E1 -mu_12/E1 0;-mu_12/E1 1/E2 0;0 0 1/G12];
%Q matrix calculation
Q=inv(S);
%Strain Vector calculation
Strain_12=S*Stress_12;
%Transformation matrix calculation
T(:,:,i)=[c(i).^2 s(i).^2 2.*s(i).*c(i); s(i).^2 c(i).^2 -2.*s(i).*c(i); -s(i).*c(i) s(i).*c(i) (c(i).^2)-(s(i).^2)];
end

Mathieu NOE
Mathieu NOE 2022 年 3 月 28 日
編集済み: Mathieu NOE 2022 年 3 月 28 日
hello
try this (T is a 3 x 3 matrix not a scalar so it must be stored in a cell)
clc
clear all
sigma1=0.002;
sigma2=-0.003;
tau_12=0.004;
E1=181;
E2=10.3;
mu_12=0.28;
G12=7.17;
tetha=1:90;
% all this could be removed from the for loop (no need to repeat all the
% time the same code )
c=cosd(tetha);
s=sind(tetha);
Stress_12=[sigma1; sigma2; tau_12];
%S matrix calculation
S=[1/E1 -mu_12/E1 0;-mu_12/E1 1/E2 0;0 0 1/G12];
%Q matrix calculation
Q=inv(S);
%Strain Vector calculation
Strain_12=S*Stress_12;
for i=1:numel(tetha)
%Transformation matrix calculation
T{i}=[c(i)^2 s(i)^2 2*s(i)*c(i);
s(i)^2 c(i)^2 -2*s(i)*c(i);
-s(i)*c(i) s(i)*c(i) (c(i)^2)-(s(i)^2)];
%Inverse of the transformation matrix
T_1{i}=inv(T{i});
end

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by