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

조회 수: 23 (최근 30일)
Nahid
Nahid 2015년 4월 10일
이동: DGM 2023년 2월 24일
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
Aravinthan Chakarapani 2021년 11월 8일
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