MATLAB: In an assignment A(I) = B, the number of elements in B and I must be the same.

??? in an assignment a(i) = bMATLABthe number of elements in b and i must be the same.

I am trying to generate value of "K" , which is a function of a,b, alpha, beta and gama
I have generate the value of K with three set of values of forsiad variables .
when i tried , i got "In an assignment A(I) = B, the number of elements in B and I must be the same" this comment as error message
My program file is code is encloded herewith
can any one help me?

Best Answer

Use cell array
format long e
%poissons ratio
pm=0.3
% eleastic modulus :E
Em=29e6;
%plate thickness
t=0.005;
% nodal co ordinates
ncord=[12.5 0;250 0;0 12.5;12.5 12.5;12.5 250;0 250;12.5 250;250 250];
% nodal connection
nconn=[1 2 4 5; 4 5 8 7;3 4 7 6];
%no of elements :nelem
nelem=3;
% no of nodes :nnode
nnode=length(ncord)
%no of degrees of freedom per node: ndof
ndof=2;
%total degree of freedom of entire system
tdof=nnode*ndof;
%no of nodes per element
nnele=4;
%no of degrees of freedom per element
edof=ndof*nnele
%length and breadth of the elememets
lelem=zeros(nelem,1)
belem=zeros(nelem,1)
lelem(1)=237.5
lelem(2)=237.5
lelem(3)=12.5
belem(1)=12.5
belem(2)=237.5
belem(3)=237.5
%a and b parameters for the elememet
for ie=1:nelem
a(ie)=lelem(ie)/2;
b(ie)=belem(ie)/2;
end
% constitutive for plane stress elements
C=(Em/(1-pm^2))*[1 pm 0;pm 1 0;0 0 (1-pm)/2];
% alpha matrix of individual elements
for ie=1:nelem
alpha{ie}=(1/(4*a(ie)*b(ie)))*[-b(ie) 0 b(ie) 0 -b(ie) 0 b(ie) 0;0 -a(ie) 0 -a(ie) 0 a(ie) 0 a(ie);-a(ie) -b(ie) -a(ie) b(ie) a(ie) -b(ie) a(ie) b(ie)];
beta{ie}=(1/(4*a(ie)*b(ie)))*[0 0 0 0 0 0 0 0;0 1 0 -1 0 -1 0 1;1 0 -1 0 -1 0 1 0];
gama{ie}=(1/(4*a(ie)*b(ie)))*[1 0 -1 0 -1 0 1 0;0 0 0 0 0 0 0 0;0 1 0 -1 0 -1 0 1];
end
%Stiffness matrix
for ie=1:nelem
k{ie}=(4*a(ie)*b(ie)*t)*transpose(alpha{ie})*C*alpha{ie}+((2*(a(ie)^3)*b(ie)*t)/3)*transpose(beta{ie})*C*beta{ie}+((2*a(ie)*(b(ie)^3)*t)/3)*transpose(gama{ie})*C*gama{ie}
end
%assemble to global stiffness matrix