Error using ==> minus Matrix dimensions must agree.

  • Follow


Hi , 

I got this message once I run my codes. How could I modify the codes so that I don't get this message anymore?

here is my codes; 
D =12; 
L=48; 
P=1000;
nu=0.3;

function uh=Displacement_field(dispX,dispY,N)
uh=[dispX'*N; dispY'*N];
return

function [eldisp,stress]=exact_sol_cantilever(x,y,P,E,nu,D,L)
%-----------------------------------------------------------------------
%  analytical solution:
%  ux=Py/(6EI)*[(6L-3x)*x+(2+poisson)*(y^2-D^2/4)];
%  uy=-P/(6EI)*[3*poisson*y^2*(L-x)+(4+5*poisson)*D^2*x/4+(3*L-x)*x^2];
%-----------------------------------------------------------------------
 
 y=y-D/2;% move (0,0) to below left corner 
I=D^3/12;
pei=P/(6*E*I);
ux=pei*y*((6*L-3*x)*x+(2+nu)*(y*y-D*D/4));
uy=-pei*(3*nu*y*y*(L-x)+(4+5*nu)*D*D*x/4+(3*L-x)*x*x);

dux=pei*6*(L-x)*y;  % element strain 
dvy=-pei*6*nu*y*(L-x);
dxy=pei*6*(1+nu)*(y*y-D*D/4); % shearing strain: duy+dvx

sigXX=P*(L-x)*y/I;
sigYY=0;
sigXY=P*(y*y-D*D/4)/2/I;

eldisp=[ux;uy];
estrain=[dux;dvy;dxy];
stress=[sigXX;sigYY;sigXY];

U_analysis=eldisp;
return

[ue,estress0]=exact_sol_cantilever(pt(1),pt(2),P,E,nu,D,L);  
uh=Displacement_field(dispX,dispY,dNdx);
error = ue-uh


Is it because of the looping? I'm starting the nodes from -ve value.
0
Reply ilyani 11/18/2010 3:33:04 PM

ilyani wrote:
> Hi ,
> I got this message once I run my codes. How could I modify the codes so 
> that I don't get this message anymore?
....

W/O specific line it's too much trouble to try to read your code...

Wherever it is, you've got a dimension mismatch just like the message 
says.  The sizes have to be conformant for the operation.

Try

size(x)
size(y)

in the function at the error line where x and y are the variables in the 
offending line and see where you've got a size error.

--
0
Reply dpb 11/18/2010 3:36:02 PM


1 Replies
1109 Views

(page loaded in 0.046 seconds)

Similiar Articles:













7/14/2012 6:28:29 PM


Reply: