This is the code I am working on for a project using MATLAB:
clc,clear
G=27.7*10.^9;
b=0.286*10.^-9;
v=0.334;
x=(-5*10.^-9:0.1:5*10.^-9);
y=(-5*10.^-9:0.1:-1*10.^-9);
[xx,yy]=meshgrid(x,y);
stress=(-G*b)*yy*(3^xx+yy^2)/(2*pi.*(1-v))*(xx^2+yy^2).^2;
figure
mesh(xx,yy,stress);
grid on
xlabel('X')
ylabel('Y')
zlabel('Stress')
Whenever I try to run this I keep getting the "Error using mesh"
line, and then an error for "mesh(xx,yy,stress)".
I know I am not catching the issue but how do I fix this? If you
could explain as well that be extremely helpful!
Following is the fixed code :
clc,clear
G=27.7*10.^9;
b=0.286*10.^-9;
v=0.334;
%
% FIX : Use proper increments for x and y, to create vectors.
%
x=(-5*10.^-9:0.1*10.^-9:5*10.^-9);
%
% FIX : Use proper increments for x and y, to create vectors.
%
y=(-5*10.^-9:0.1*10.^-9:-1*10.^-9);
[xx,yy]=meshgrid(x,y);
%
% FIX : Use dot-operations between vectors, so that "stress" is also a vector.
%
stress=(-G*b).*yy.*(3.^xx+yy.^2)./(2*pi.*(1-v)).*(xx.^2+yy.^2).^2;
figure
mesh(xx,yy,stress);
grid on
xlabel('X')
ylabel('Y')
zlabel('Stress')
Following is the plot :
Get Answers For Free
Most questions answered within 1 hours.