How to plot an implicit and dicontinues function?
2 次查看(过去 30 天)
显示 更早的评论
Francisco Patitucci Perez
2020-10-23
评论: Francisco Patitucci Perez
2020-10-24
Hello, I want to ask how to plot the level curves of this function. I have tried with fimplicit and with fcontour but I can't plot it because of its discontinuities. If anyone knows it will be very helpful because it is for my composite structures course.
function [z] = THb(x1,x2)
E1 = 100*10^3;E2 = 7*10^3;nu12=.3;F1t=1000;F2t=45;F1c=600;F2c=150;F6=65;
if x1>=0
A=1/F1t^2;
C=-(1/F1t^2);
else
A=1/F1c^2;
C=-(1/F1c^2);
end
if x2>=0
B=1/F2t^2;
else
B=1/F2c^2;
end
z=A*x1.^2 + B*x2.^2 +C*x1.*x2;
end
0 个评论
采纳的回答
Alan Stevens
2020-10-24
Do you mean like this (type doc contour for more detail):
x1 = -2:0.01:2;
x2 = -2:0.01:2;
[x, y] = meshgrid(x1, x2);
z = THb(x,y);
lvls = [1 2 5 10 15 20 40 60]*10^-6; % Set the contour values you want to see
contour(x,y,z,lvls,'ShowText','on')
xlabel('x1'),ylabel('x2'),zlabel('z')
... etc.
更多回答(1 个)
Alan Stevens
2020-10-24
Something like the following? (You could use surfc if you want contours as well):
x1 = -10:10;
x2 = -10:10;
[x, y] = meshgrid(x1, x2);
z = THb(x,y);
surf(x,y,z)
xlabel('x1'),ylabel('x2'),zlabel('z')
function [z] = THb(x1,x2)
E1 = 100*10^3;E2 = 7*10^3;nu12=.3;F1t=1000;F2t=45;F1c=600;F2c=150;F6=65;
if x1>=0
A=1/F1t^2;
C=-(1/F1t^2);
else
A=1/F1c^2;
C=-(1/F1c^2);
end
if x2>=0
B=1/F2t^2;
else
B=1/F2c^2;
end
z=A*x1.^2 + B*x2.^2 +C*x1.*x2;
end
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!