How can I get rid of this error? Please help me guys

E = 10e7; poisson = 0.30;
C=E/(1-poisson^2)*[1 poisson 0;poisson 1 0;0 0 (1-poisson)/2];
P = 1e6;
Lx=5; Ly=1;
numberElementsX=20;
numberElementsY=10;
numberElements=numberElementsX*numberElementsY;
[nodeCoordinates, elementNodes] =rectangularMesh(Lx,Ly,numberElementsX,numberElementsY);
xx=nodeCoordinates(:,1);
yy=nodeCoordinates(:,2);
drawingMesh(nodeCoordinates,elementNodes,'Q4','k-');
numberNodes=size(xx,1);
GDof=2*numberNodes;
stiffness=formStiffness2D(GDof,numberElements,elementNodes,numberNodes,nodeCoordinates,C,1,1); % boundary conditions
fixedNodeX=find(nodeCoordinates(:,1)==0);
fixedNodeY=find(nodeCoordinates(:,1)==0); % fixed in YY
prescribedDof=[fixedNodeX; fixedNodeY+numberNodes];
force=zeros(GDof,1);
rightBord=find(nodeCoordinates(:,1)==Lx);
force(rightBord+numberNodes)=P*Ly/numberElementsY;
force(rightBord(1)+numberNodes)=P*Ly/numberElementsY/2;
force(rightBord(end)+numberNodes)=P*Ly/numberElementsY/2;
displacements=solution(GDof,prescribedDof,stiffness,force);
% displacements and deformed shape
disp('Displacements')
jj=1:GDof; format f=[jj; displacements'];
fprintf('node U\n') fprintf('%3d %12.8f\n',f)
UX=displacements(1:numberNodes); UY=displacements(numberNodes+1:GDof);
scaleFactor=0.1; figure
drawingField(nodeCoordinates+scaleFactor*[UX UY],elementNodes,'Q4',UX);%U XX hold on
drawingMesh(nodeCoordinates+scaleFactor*[UX UY],elementNodes,'Q4','k-');
drawingMesh(nodeCoordinates,elementNodes,'Q4','k--');
colorbar
title('U XX (on deformed shape)')
axis off
% stresses at nodes stresses2D(GDof,numberElements,elementNodes,numberNodes,nodeCoordinates,displacements,UX,UY,C,scaleFactor);
''Undefined function or variable "nodeCoordinates".''
[nodeCoordinates, elementNodes] =rectangularMesh(Lx,Ly,numberElementsX,numberElementsY);

6 Comments

Dear ISLAM
I have same problem can you help me please thanks
What happened after you downloaded the code from the springer site and added the directory to your path?
Hello to you all i have the same problem and i can not find anywhere the function drawingField and the drawingMesh from the above problem. Does anyone have solved it ???? i need it for my thesis.
Thanks
huan ma
huan ma on 18 Aug 2021
Moved: DGM on 24 Feb 2023
Hello, have you solved your problem, how to get this rectangularmesh.m, I'm learning the program in the book, but can't find this file in the book
Dear friend,I want to know how this drawingmesh function is implemented
It has a switch on the requested element type, and calls plot3() or patch() as appropriate.

Sign in to comment.

Answers (2)

READ THE ERROR MESSAGE.
So where in this script have you defined the variable nodeCoordinatea?
It was generated by rectangularMesh, a code that is NOT supplied by MathWorks. Try this:
which rectangularMesh -all
Do you have that function? If not, then you will need to download it, as well as its companions from this site:

4 Comments

Hey John do you have these functions from that book for Windows? Will be greatly appreciated. Thanks
Why would I have them? All I did was use Google search.
The link I gave takes you to a page where you can download the files. I just tried it, and it indeed seems to download files. So surely you can click for yourself just as easily.
I downloaded the files and I tried to execute this file: rectangular Mesh.p but this message appears "Warning: The P-code file MATLABsoftware_rectangularMesh.p was generated prior to MATLAB version 7.5 (R2007b) and will Use MATLABsoftware_rectangularMesh.p using MATLAB R2007b or later. " How do I correct this error? Help me please.
You can hope that nothing bad happens, but if it fails then you would have to go back go Springer to ask them to update the file, which they would pass along to the author of the book. However I would tend to doubt there would be any actual result.
Alternately if you do not have a Student license (not sure about a Home license) then you can probably use your existing license to access MATLAB R2007a and run the code with that.

Sign in to comment.

You can use following rectangularMesh function to generate the same parameters. I hope this works for your code.
function [nodeCoordinates,elementNodes] = rectangularMesh(Lx,Ly,...
numberElementsX,numberElementsY)
xx = 0:Lx/numberElementsX:Lx;
yy = 0:Ly/numberElementsY:Ly;
[XX YY] = meshgrid(yy,xx);
nodeCoordinates = [YY(:),XX(:)];
elementNodes = zeros(numberElementsX*numberElementsY,4);
j = 1;
i =1;
i1 =0;
counter = 0;
for j = 1:numberElementsY
for i =1: numberElementsX
counter = counter +1;
if i ==1 && j==1
i1 =1;
else
i1 = i1 +1;
end
i2 = i1 + 1;
i4 = i1 + numberElementsX + 1;
i3 = i2 + numberElementsX + 1;
elementNodes(counter,:) = [i1 i2 i3 i4];
end
i1 = i1+1;i2 = i2+1;
end
end

8 Comments

you have function drawingMesh??
hello Walter Roberson. I have problem when I run function drawingMesh as show: The P-code file
D:\testchunhat\Newfolder\FerreiraCodes_Improved-master\drawingMesh.p was generated prior to MATLAB version 7.5 (R2007b) and is no longer supported. Use pcode to regenerate the file using MATLAB R2007b or later.
I think rawingMesh.p don't run in matlab 2021? You can help me aboud error?
You should ask the author and/or the maintainer of the code to regenerate the P-code file in a newer release.
https://www.springer.com/us/book/9783030479510 seems to be a 2020 version of the book, so you could probably get updated copies.
Hi there Waqas!
How did you get the codes for rectangularmesh? If you wrote it yourself, do you also happen to have codes suitable for drawingmesh?
Hi Arvinthan,
Yes I wrote the code myself for the rectangular mesh. I dont remember writing a drawingmesh.

Sign in to comment.

Tags

Asked:

on 10 Apr 2015

Moved:

DGM
on 24 Feb 2023

Community Treasure Hunt

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

Start Hunting!