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

6 次查看(过去 30 天)
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 个评论
ni
ni 2023-2-24
Dear friend,I want to know how this drawingmesh function is implemented
Walter Roberson
Walter Roberson 2023-2-24
It has a switch on the requested element type, and calls plot3() or patch() as appropriate.

请先登录,再进行评论。

回答(2 个)

John D'Errico
John D'Errico 2015-4-10
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 个评论
loukmane el khaldi
loukmane el khaldi 2019-5-14
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.
Walter Roberson
Walter Roberson 2019-5-14
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.

请先登录,再进行评论。


waqas
waqas 2019-8-26
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 个评论
Aravinthan Chakarapani
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?
waqas
waqas 2021-11-10
Hi Arvinthan,
Yes I wrote the code myself for the rectangular mesh. I dont remember writing a drawingmesh.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by