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!