Not working, mohr circle
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I try to execute the program, but its not working. I need to plot a circle (Mohr Circle) and display some results.
Sigmax=-60; %Normal Stress X Axis
Sigmay=90; %Normal Stress Y Axis
Tauxy=30; %Shear Stress
theta=-25; %Rotation of element
%Stresses in terms of the rotated coordinate
Sigmaxp=0.5*(Sigmax+Sigmay)+0.5*(Sigmax-Sigmay)*cos(2*theta)+Tauxy*sin(2*theta);
%Normal Stress X2 Axis
Sigmayp=0.5*(Sigmax+Sigmay)-0.5*(Sigmax-Sigmay)*cos(2*theta)-Tauxy*sin(2*theta);
%Normal Stress Y2 Axis
Tauxpyp=-0.5*(Sigmax+Sigmay)-0.5*(Sigmax-Sigmay)*cos(2*theta)-Tauxy*sin(2*theta); %Shear Stress
SigmaAve=0.5*(Sigmax+Sigmay); %Average Stress
r=(((0.5*(Sigmax-Sigmay))^2)+Tauxy^2);
MaximumStress=SigmaAve+r; %Maximum Principal Stress
MinimumStress=SigmaAve-r; %Minimum Principal Stress
MaximumTau=((0.5*(Sigmax-Sigmay))^2+Tauxy^2)^0.5;
Principaltheta1=0.5*arctan((2*Tauxy)/(Sigmax-Sigmay));
Principaltheta2=90+Principaltheta1;
Secondarytheta1=0.5*arctan((Sigmax-Sigmay)/(2*Tauxy));
Secondarytheta2=90+Secondarytheta1;
Display Sigmaxp;
Display Sigmayp;
Display Tauxpyp;
Display MaximumStress;
Display MinimumStress;
Display MaximumTau
Display Principaltheta1;
Display Principaltheta2;
Display Secondatytheta1;
Display Secondarytheta2;
function circle(SigmaAve,0,r);
%SigmaAve and 0 are the coordinates of the circle
%r is the radius of the circle
%0.01 is the angle step
ang=0:0.01:2*pi;
xp=R*cos(ang);
yp=R*sin(ang);
plot(x+xp,y+yp);
end
>> P8
Error: File: P8.m Line: 27 Column: 1
Function definitions are not permitted in this context.
1 comentario
Image Analyst
el 21 de Jun. de 2015
Try these links: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
Also, FUNCTION and END must be lower case, and you need to have Display defined somewhere.
I have no idea what went wrong, because you didn't say, but we will after you read that first link I gave you and you fix your post. Just to be clear POST ALL THE RED ERROR TEXT!
Respuestas (1)
Geoff Hayes
el 22 de Jun. de 2015
Maria - the error message is telling you that have incorrectly setup your MATLAB file, P.m. You cannot include a function within a script (like you have done) but should either create a new file (for this function) or embed rework your script into a function (which will allow multiple functions to be defined in the same file).
It isn't clear to me why the first 26 lines precede the function definition as they don't provide any data to or even call the circle function.
Note also how your function has been defined
function circle(SigmaAve,0,r);
%SigmaAve and 0 are the coordinates of the circle
%r is the radius of the circle
%0.01 is the angle step
ang=0:0.01:2*pi;
xp=R*cos(ang);
yp=R*sin(ang);
plot(x+xp,y+yp);
end
You pass in SigmaAve as a variable but do not use it anywhere in the functionb body. The second input is a number (zero) when you should be using a variable to represent this number. Finally, the third input parameter is r but you are referencing it as R in the function body. (This mismatch will cause an error to be thrown.)
0 comentarios
Ver también
Categorías
Más información sobre Stress and Strain en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!