User login

Navigation

You are here

LOOP ERROR IN MATLAB

Zuhaib Nazir's picture

Dear Researchers

 

Can you please make a correction in my Code of MATLAB

X1=[1,2,3,4]';

X2=[5,6,7,8]';

U1=[9,10,11,12]';

U2=[13,14,15,16]';

for i=1:1:4

EPS1(i,1)= U1(i,1)/X1(i,1);

EPS2(i,1)= U2(i,1)/X2(i,1);

EPS12(i,1)= 0.5*((U1(i,1)/X2(i,1))+(U2(i,1)/X1(i,1)));

defG(i)=[1+U1(i,1)/X1(i,1) 0+U1(i,1)/X2(i,1); 0+U2(i,1)/X1(i,1) 1+U2(i,1)/X2(i,1)];

end

EPS11

EPS22

EPS12

are right but for defoarmation gradient  i am getting error of 

 

Subscripted assignment dimension mismatch.

Error in strains (line 11)

defG(i)=[1+U1(i,1)/X1(i,1) 0+U1(i,1)/X2(i,1); 0+U2(i,1)/X1(i,1) 1+U2(i,1)/X2(i,1)];

 

Kindly correct me where I am wrong.

 

Regards

Zuhiab

Comments

yawlou's picture

defg(i) is the single element, i, of a 1 dimensional array and you are setting it equal to a 2x2 matrix array.  This seems to be the problem.

You probably want defg=[1+U1(i,1)/X1(i,1) 0+U1(i,1)/X2(i,1); 0+U2(i,1)/X1(i,1) 1+U2(i,1)/X2(i,1)]; in which case defg will be a 2x2 array containing your deformation gradient in 2 dimensions.

Subscribe to Comments for "LOOP ERROR IN MATLAB"

Recent comments

More comments

Syndicate

Subscribe to Syndicate