Combining smaller matrices into a bigger one via a loop
1 回表示 (過去 30 日間)
古いコメントを表示
clc;
Ln=5;%input('Length between node''Ln');
Bn=2.5;%input('Beam between node''Bn');
h=0.02;%input('Plate thickness between node''h');
M=7600;%input('Mass of the Helicopter''M');
Lweb=0.07;%input('Length of web of the stiffner''Lweb');
Lf=0.07;%input('Length of flange of the stiffner''Lf');
Tweb=0.015;%('web thickness''Tweb');
Tf=0.015;%('flange thickness''Tf');
Ss=0.4;%input('Stiffners Spacing''Ss');
ymax=0.005;%input('Maximum Displacement of materials''ymax');
E=207*10^9;
Es=69*10^9;
G=69*10^12;
g=9.81;
% Area of Hellideck
Ah=Bn*Ln;
Aweb=2*Tweb;
Af=Lf;
%As=Aweb+Af;
% Total length of stiffner
LTf=Aweb+Af
% Number of longtidunal Spacing
L1=LTf+Ss;
Nl=Ln/L1
Nv=Bn/L1
Np=Nl*12
Nl1=2*Nl
%Nl2=hm.Nl1
%Nl3=int(Nl2)
Nv1=4*Nv;
%Nv2=int(Nv1)
K11=zeros(Np,Np);
%K1=zeros(Nv1,Nl1)
Iy=(Ss*h^3)/12;
Iz=(h*Ss^3)/12;
F=M*g;
Q=0
K=zeros(30,60)
for L=L1:L1:Ln
q=F/L;
for B=L1:L1:Bn
As=h*B;
A=(As*E)/L;
I=(B*h^3)/12;
Asy=B*h;
Qy=(12*E*Iz)/(G*Asy.*L^2);
By=(E.*I)/((1+Qy).*L^3);
Qz=(12*E*Iy)/(G*Asy.*L^2);
Bz=(E*Iy)/((1+Qz).*L^3);
R=[1,0,0,0,0,0,-1,0,0,0,0,0;0,cos(Q),sin(Q),0,cos(Q),sin(Q),0,cos(Q),sin(Q),0,cos(Q),sin(Q);0,-sin(Q),cos(Q),0,-sin(Q),cos(Q),0,-sin(Q),cos(Q),0,-sin(Q),cos(Q);0,0,0,-1,0,0,0,0,0,1,0,0;0,-cos(Q),-sin(Q),0,-cos(Q),-sin(Q),0,-cos(Q),-sin(Q),0,-cos(Q),-sin(Q);0,sin(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%k11=sum(:1,) :12:Np
% applying downbary conditions
KG(12,:)=[];
KG(:,12)=[];
KG(11,:)=[];
KG(:,11)=[];
KG(10,:)=[];
KG(:,10)=[];
KG(8,:)=[];
KG(:,8)=[];
KG(7,:)=[];
KG(:,7)=[];
KG(6,:)=[];
KG(:,6)=[];
k=KG
f(12,:)=[];
f(11,:)=[];
f(10,:)=[];
f(8,:)=[];
f(7,:)=[];
f(6,:)=[];
end
end
%%The KGs are displayed but id loved to have them arranged into a bigger
%%matrix such that once the inner loops finish running all KG from it at
%%every time should be concanated vertically for every set of B untill the
%%L is exhausted.the final matrix size that KG should for is a 30 by 60
%%matrix of combined KG
Hi experts,
I'm quite new to matlab and I have a problem.im working on an FEA project and I'm required to write a simple code that combines the matrices into the K zeros matrix in a get in a certain order. The smaller matrices for each KG and the code prints them out from the two for loops which are 50 in number correctly.but it is expected to arrange or cantecate those KG matrix vertically once the inner for loop runs and keep that progress until the entire outer loops finishes. I have done Alot of internet search for a few weeks and nothing is working .please help me. here is the code
5 件のコメント
回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!