跪求怎么用MATLAB解不等式并画图
P1和P2是变量,n a b是参数,怎么求解上式M>0或M<0P1和P2的取值范围呢?P1和P2的关系为a<P2<P1<b;另外 0<n<1 展开
n=0.8;%自己改
a=-3;%自己改
b=5;%自己改[P1,P2]=meshgrid(linspace(a,b));
subplot 121;
M=@(P1,P2)b^2/(4*(a - b)) - P2*n.*(((P1 - a).*(P2 - b))/(a - b)^2 - ((P1 - b).*(P1 - a - P2*n + a*n))./((a - b)^2*(n - 1))) - (P1.*(P1 - b).*(P1 - b - P2*n + b*n))./((a - b)^2*(n - 1));
Z=max(M(P1,P2),P2-P1);
contourf(P1,P2,-Z,[0 0],'facecolor','r','edgecolor','none');
xlabel('P1');ylabel('P2');
title('M<0;a<P2<P1<b');
axis equal;
subplot 122;
Z=max(-M(P1,P2),P2-P1);
contourf(P1,P2,-Z,[0 0],'facecolor','r','edgecolor','none');
xlabel('P1');ylabel('P2');
title('M>0;a<P2<P1<b');
axis equal;