Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to construct Matlab patch?

Subject: how to construct Matlab patch?

From: ilyani

Date: 21 Sep, 2010 10:50:07

Message: 1 of 5

I'm calculating the error in displacement and energy norm using matlab codes. However, I am failed getting their values. anyone could show me how to make a patch test on my case for a timoshenko beam?

thanks

Subject: how to construct Matlab patch?

From: Sean

Date: 21 Sep, 2010 14:35:21

Message: 2 of 5

"ilyani " <dyeyanie@yahoo.com> wrote in message <i7a2ku$i8q$1@fred.mathworks.com>...
> I'm calculating the error in displacement and energy norm using matlab codes. However, I am failed getting their values. anyone could show me how to make a patch test on my case for a timoshenko beam?
>
> thanks

Show us what you've done, commented, in code.

Subject: how to construct Matlab patch?

From: ilyani

Date: 21 Sep, 2010 19:24:05

Message: 3 of 5

%--------------------------------------------------------------------------
% ERROR IN DISPLACEMENT NORM

ely=(2*c)/numY;enorm=0; %ely = element length at y axis between 2 points
x_count = 1;
y_count = 1;
% for XX =1:max(nodex); % starting the loop by determine the nodes in x axis
for XX = linspace(0,L,nodex) % starting the loop by determine the nodes in x axis
    jj=-c;
% for YY =1:max(nodey); % looping for nodes in y axis
    for YY = linspace(-c,c,nodey)
        pei=P/(6*E*I);
        u_x(x_count,y_count)=-pei*YY*(((6*L-3*XX)*XX)+((2+nu)*(YY*YY)-(c*c))); % exact displacement for x axis
        u_y(x_count,y_count)=pei*(3*nu*YY*YY*(L-XX)+(4+5*nu)*(c*c)*XX+(3*L-XX)*(XX*XX)); % exact displacement for y axis
        jj=jj+ely;
        dvec=(U(xs)-u_x(x_count,y_count)).^2+(U(ys)-u_y(x_count,y_count)).^2; % dvec; error in displacement = FEM displacement substract with exact displacement
        err=dvec.^2;
        enorm = enorm + err;
        y_count = y_count + 1;
    end
    x_count = x_count + 1;
end
 enorm = sqrt (enorm)
 
% % ERROR IN ENERGY NORM
% K1=K;
% ely=(2*c)/numY;enorm=0; %ely = element length at y axis between 2 points
x_count = 1;
y_count = 1;
for XX=L/2;
   for YY = linspace(-c, c, nodey);
% for XX = linspace(0,L,nodex) % starting the loop by determine the nodes in x axis
    jj=-c;
% for YY =1:max(nodey); % looping for nodes in y axis
% for YY = linspace(-c,c,nodey)
         jj=jj+ely;
stress = C*B*U(sctrB);
stressex(XX,YY) = -(1/I)*P*(L-XX)*YY;
stressex(XX,YY) = 0;
stressex(XX,YY) = -0.5*(P/I)*(c^2 - YY^2);
err = stress-stressex(XX,YY);
y_count = y_count + 1;
    end
    x_count = x_count + 1;
end
% EU=0.5*U'*K1*U; % strain energy for numerical
enorm2 = sqrt (err)

hi, these are the codes that i've commented however the errors getting bigger once I increased the element number and I can't obtained ans for err = stress-stressex(XX,YY); I would like to calculate the value of stresses for coordinate XX=L/2 and YY=from -c to c.

Subject: how to construct Matlab patch?

From: Sean

Date: 21 Sep, 2010 20:00:22

Message: 4 of 5

> enorm=0; %ely = element length at y axis between 2 points

> dvec=(U(xs)-u_x(x_count,y_count)).^2+(U(ys)-u_y(x_count,y_count)).^2; % dvec; error in displacement = FEM displacement substract with exact displacement
> err=dvec.^2;
> enorm = enorm + err;

> enorm = sqrt (enorm)

 Isolating these lines you can see that you're double squaring dvec i.e. the original call calculates the sum of squares, then you square that, add it to the non-squared enorm and then only take one square root once.

Subject: how to construct Matlab patch?

From: ilyani

Date: 21 Sep, 2010 20:26:04

Message: 5 of 5

thnx for your reply.

the reason why I squaring the dvec is because I would like to form a dot product there which originally is dvec.dvec and followed by a integrating the sum of dvec.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us