index exceeds array bounds

%%%%I am trying to create a programm which gets values from an excel file
for fl=1:1:dof(de,4)
for i=1:1:ne
CKx(fl)=sum(b(i)*ckx(i))./sum(b(i));
CKy(fl)=sum(c(i)*cky(i))./sum(c(i));
end
end

9 Commenti

here
fl=3
ne=29
b and c is vector,
ckx and cky is matrix size 29 by 1
this is only part of the programming in which i am getting error.
If you try to access more number of elements then present, then you will get this error.
A = rand(1,5) ;
A(6) % error
sir what did you want more information?
%%this is my complelte programming
clear;
%--------------------------------------------------------------------------
inpf=input('File name of input file data ','s');
M=importdata([inpf,'.xlsx']);
nod=M.data.Node;
nj=max(nod(:,1));
elem=M.data.Element;
ne=max(elem(:,1));
Ec=[];
Ec=elem(:,5);
pc=[];
pc=elem(:,8);
bc=elem(:,6);
dc=elem(:,7);
% %--------------------------------------------------------------------------
for i=1:ne
xf=nod(elem(i,3),2);
x0=nod(elem(i,2),2);
yf=nod(elem(i,3),3);
y0=nod(elem(i,2),3);
zf=nod(elem(i,3),4);
z0=nod(elem(i,2),4);
L(i,1)=sqrt((xf-x0)^2+(yf-y0)^2+(zf-z0)^2);
A(i,1)=elem(i,6)*elem(i,7);
Izz(i)=elem(i,6)*(elem(i,7)^3)/12;
Iyy(i)=elem(i,7)*(elem(i,6)^3)/12;
ckx(i)=xf;
cky(i)=yf;
xcgf(i,1)=elem(i,12);
ycgf(i,1)=elem(i,13);
end
%%DOF of the element..............
dof=[];
for de=1:1:ne
dof(de,1)=elem(de,1);%Element Number
dof(de,2)=elem(de,2);%First node number
dof(de,3)=elem(de,3);%Second node number
dof(de,4)=elem(de,4);%Floor Number
for fl=1:1:dof(de,4)
dof(de,5)=1+(fl-1)*3;
dof(de,6)=2+(fl-1)*3;
dof(de,7)=3+(fl-1)*3;
dof(de,8)=4+(fl-1)*3;
dof(de,9)=5+(fl-1)*3;
dof(de,10)=6+(fl-1)*3;
end
end
% % % %Generation of element stiffness matrix for Columns
% % %--------------------------------------------------------------------------
for i=1:1:ne
b=12*Ec(i).*Iyy(i)/(L(i).^3);
c=12*Ec(i).*Izz(i)/(L(i).^3);
d=b.*xcgf(i);
e=(c.*(xcgf(i)).^2)+(b*(ycgf(i)).^2);
end
% center of stiffness of each floor level
for fl=1:1:dof(de,4)
for i=1:1:ne
CKx(fl)=sum(b(i).*ckx(i))./sum(b(i));
CKy(fl)=sum(c(i).*cky(i))./sum(c(i));
end
end
KALYAN ACHARJYA
KALYAN ACHARJYA il 30 Set 2020
Modificato: KSSV il 30 Set 2020
@KSSV shown an example for a similar error. Suppose you have an array "A" having length 5
A = rand(1,5) ;
Now if you want to access the 6th index element of A,then it shows the simmilar error, as A have length 5th only.
A(6) % error
Same case may happen in your code, you want to access the particular index element from the data file, but its exceeds its actual length/size
Kalyan Acharjya sir please resolve my problem.
Sir, Sure I will try
KSSV
KSSV il 30 Set 2020
@Pramod we cannot help you unless we know your complete code and the variables.

Accedi per commentare.

Risposte (1)

KSSV
KSSV il 30 Set 2020
m = dof(de,4) ; % I hope this is a number
ne = length(b) ; % dimensions of b and ckx, cky should be same
Ckx = cell(m,ne) ; % cell because I assume the ouput stored is array as you have used ./
Cky = cell(m,ne) ;
for fl=1:1:m
for i=1:1:ne
CKx{fl,i}=sum(b(i)*ckx(i))./sum(b(i));
CKy{fl,i}=sum(c(i)*cky(i))./sum(c(i));
end
end

Categorie

Prodotti

Release

R2018a

Richiesto:

il 30 Set 2020

Risposto:

il 30 Set 2020

Community Treasure Hunt

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

Start Hunting!

Translated by