Effacer les filtres
Effacer les filtres

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

8 vues (au cours des 30 derniers jours)
Nahid
Nahid le 10 Avr 2015
Déplacé(e) : DGM le 24 Fév 2023
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 commentaires
ni
ni le 24 Fév 2023
Dear friend,I want to know how this drawingmesh function is implemented
Walter Roberson
Walter Roberson le 24 Fév 2023
It has a switch on the requested element type, and calls plot3() or patch() as appropriate.

Connectez-vous pour commenter.

Réponses (2)

John D'Errico
John D'Errico le 10 Avr 2015
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 commentaires
loukmane el khaldi
loukmane el khaldi le 14 Mai 2019
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 le 14 Mai 2019
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.

Connectez-vous pour commenter.


waqas
waqas le 26 Août 2019
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 commentaires
Aravinthan Chakarapani
Aravinthan Chakarapani le 8 Nov 2021
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 le 10 Nov 2021
Hi Arvinthan,
Yes I wrote the code myself for the rectangular mesh. I dont remember writing a drawingmesh.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by