CODE:
function phaseplot(varargin)
type=varargin{end};
switch type
case'2'
t=varargin{1};%温度
y_1=varargin{2};%液相线
y_g=varargin{3};%气相线
y2i=linspace(0,1);ti=spline(y_1,t,y2i);plot(y_1,t,'o',y2i,ti);
hold on
y1i=linspace(0,1);t1i=spline(y_g,t,y2i);plot(y_g,t,'o',y1i,t1i);
prompt={'物质1的名称','物质2的名称'};
answer=inputdlg(prompt,'请输入物质名称',1);
text('position',[0 min(t)],'string',[answer{1},'(A)']);
text('position',[0.86 min(t)],'string',[answer{2},'(A)']);
xlabel('x_A');ylabel('tC');title('二元相图');
text(0.5,tli(50)+5,'气相');text(0.8,min(ti)+1,'液相');
case'3'
y1=varargin{1};y2=varargin{2};y3=varargin{3};
c=0:0.1:0.5;b=c.*tan(pi/3);plot(c,b);axis([0 1 0 1]);
axis(axis);hold on;c=0.5:0.1:1;a=(1-c).*tan(pi/3);plot(c,a);
y=y1.*sin(pi/3);a1=(1-(y2+y3))./2;x=y2+a1;plot(x,y,'o',x,y);
prompt={'物质1的名称','物质2的名称','物质3的名称'};
answer=inputdlg(prompt,'请输入物质名称',1);
prompt1={[answer{2},'在',answer{3},'溶解度'],[answer{3},'在',...
answer{2},'溶解度']};
answer1=inputdlg(prompt1,'请输入溶解度',1);
x1=[str2num(answer1{2}) x str2num(answer1{1})];y1=[0 y 0];
plot(x1,y1,'o',x1,y1);text('pos',[0.5 0.9],'str',[answer{1},'(A)']);
text('pos',[0.01,0.05],'str',[answer{3},'(B)']);
text('pos',[0.96,0.05],'str',[answer{2},'(C)']);
text(0.75,0.5,'A%');text(0.20,0.5,'B%');text(0.5,0.04,'C%');
title('三元相图');
end