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 Commenti

madhan ravi
madhan ravi il 20 Lug 2020
Revived your question from the spam quarantine.
Thanks!

Accedi per commentare.

 Risposta accettata

madhan ravi
madhan ravi il 20 Lug 2020

1 voto

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

2 Commenti

Thank you again. Great help!
madhan ravi
madhan ravi il 20 Lug 2020
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange

Prodotti

Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by