24小时热门版块排行榜    

查看: 5533  |  回复: 2

zyj8119

木虫 (著名写手)

[交流] 【原创】给大家一个画相图的MATLAB程序 已有2人参与

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

输入过程为:
>> HAC=[0.542 0.624 0.647 0.512 0.430 0.365 0.328];
>> C6H6=[0.372 0.234 0.159 0.0367 0.0227 0.0172 0.0137];
>> H2O=[0.0857 0.140 0.1942 0.445 0.545 0.617 0.658];
>> phaseplot(HAC,C6H6,H2O,'3');
最终的相图为:
回复此楼
好好学习,天天向上。
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

Fly_2010

银虫 (小有名气)


小木虫(金币+0.5):给个红包,谢谢回帖
送鲜花一朵
好东西,正要用,方便了我们这些个不会编程得了
2楼2011-10-11 16:49:31
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

ksayw44

新虫 (初入文坛)


小木虫: 金币+0.5, 给个红包,谢谢回帖
大神,有没有二元相图的画法。
3楼2016-12-29 20:52:47
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zyj8119 的主题更新
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见