Confused about why this doesnt work at the end. The arrays all have the correct dimensions. Any help would be appreciated.
A=3;
E=4;
I=5;
le=2;
thetae=[pi/2;pi/4;pi/6];
c=cos(thetae);
s=sin(thetae);
N=numel(thetae); %counts elements of thetae vector
T=cell(1,N);
keprime=cell(1,N); %makes empty celled matrix
for i=1:N
keprime{i}=[A*E/le,0,0,-A*E/le,0,0;
0,12*E*I/le^3,6*E*I/le^2,0,-12*E*I/le^3,6*E*I/le^2;
0,6*E*I/le^2,4*E*I/le,0,-6*E*I/le^2,2*E*I/le;
-A*E/le,0,0,A*E/le,0,0;
0,-12*E*I/le^3,-6*E*I/le^2,0,12*E*I/le^3,-6*E*I/le^2;
0,6*E*I/le^2,2*E*I/le,0,-6*E*I/le^2,4*E*I/le];
end
for i=1:N
T{i}=[c(i),s(i),0,0,0,0; %Transfer Matrix set translates global coordinates to local coordinates
-s(i),c(i),0,0,0,0;
0,0,1,0,0,0;
0,0,0,c(i),s(i),0;
0,0,0,-s(i),c(i),0;
0,0,0,0,0,1];
end
T1=T(1);
T2=T(2);
T3=T(3);
ke1=T1.'*keprime(1)*T1;
ke2=T2.'*keprime(2)*T2;
ke3=T3.'*keprime(3)*T3;

댓글 수: 2

madhan ravi
madhan ravi 2020년 7월 20일
Revived your question from the spam quarantine.
JONATHAN DAVID JR FREEMAN
JONATHAN DAVID JR FREEMAN 2020년 7월 20일
Thanks!

댓글을 달려면 로그인하십시오.

 채택된 답변

madhan ravi
madhan ravi 2020년 7월 20일

1 개 추천

After the second loop use {} instead of () by the way those two loops can be reduced to one single loop.

댓글 수: 2

JONATHAN DAVID JR FREEMAN
JONATHAN DAVID JR FREEMAN 2020년 7월 20일
Thank you again. Great help!
madhan ravi
madhan ravi 2020년 7월 20일
I don’t know why there is an exhaustive first loop , you don’t seem to change anything in each iteration. Simply repmat() tk replicate the elements.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by