Combining smaller matrices into a bigger one via a loop

2 views (last 30 days)
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(Q),-cos(Q),0,sin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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 Comments
rees adah
rees adah on 28 Oct 2018
Thanks Walter for editing the question. My problem is how to fill up the K zero matrix with the sets of KG that are output from the loop which are a 6 by 6 matrix such that for every inner loop they are cancanated vertically into the K zero matrix.i was thinking if one could use multidimensional arrays to store up all the KG smaller matrices and then out of the loops do a fresh arrangement buh none of them worked
rees adah
rees adah on 28 Oct 2018
Please can I get some help?I was wondering if I could combine all the subsequent matrix into a multidimensional array on different pages and store them there for use later...is there a way I could do that via the inner loop?it didn't work for me

Sign in to comment.

Answers (1)

rees adah
rees adah on 31 Oct 2018
Please how do I store all the output of the KG matrices(50 of (6* 6)) from the loops into a multidimensional k array?I really need need plz
  6 Comments
rees adah
rees adah on 31 Oct 2018
I get the error "subscript indices must be real positive integers or logical"...I really dont know what else to do...can't I store all of the k values into a multidimensional array?
rees adah
rees adah on 5 Nov 2018
Please could you help check or run to see it? It's not storing into the K multidimensional array..any help will be appreciated

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!