加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ternDemo5.m 2.25 KB
一键复制 编辑 原始数据 按行查看 历史
slandarer 提交于 2023-04-18 15:01 . add & push by Matlab
% ternary demo5
% ----------------------
% @author : slandarer
% 公众号 : slandarer随笔
% 知乎 : slandarer
figure('Name','ternary demo5','Units','normalized','Position',[.05,.2,.42,.56])
% 初始化三元相图(Init ternary plot)
STA=STernary();
% 随机构造数据(Randomly generated data)
Pnt1=mvnrnd([10,30,10],[15 0 0;0 20 0;0 0 12],80);
Pnt2=mvnrnd([30,10,15],[25 0 0;0 15 0;0 0 40],80);
Pnt3=mvnrnd([25,10,35],[35 0 0;0 20 0;0 0 30],80);
% 数据归一化(Normalization)
Pnt1=STA.SNormByLim(Pnt1,[-5,50,-5,50,-5,50]);
Pnt2=STA.SNormByLim(Pnt2,[-5,50,-5,50,-5,50]);
Pnt3=STA.SNormByLim(Pnt3,[-5,50,-5,50,-5,50]);
% 绘制散点图(Draw scatter)
propCell={80,'filled','LineWidth',1,'MarkerEdgeColor',[1 1 1]*.3,'MarkerFaceColor'};
STA.SScatter(Pnt1(:,1),Pnt1(:,2),Pnt1(:,3),propCell{:},[0.4,0.76,0.65]);
STA.SScatter(Pnt2(:,1),Pnt2(:,2),Pnt2(:,3),propCell{:},[1,0.55,0.38]);
STA.SScatter(Pnt3(:,1),Pnt3(:,2),Pnt3(:,3),propCell{:},[0.55,0.63,0.8]);
%% ------------------------------------------------------------------------
% 已废弃写法(Obsolete method)
% % 计算凸包(Get convhull)
% [X1,Y1]=STA.ternData(Pnt1(:,1),Pnt1(:,2),Pnt1(:,3));
% [X2,Y2]=STA.ternData(Pnt2(:,1),Pnt2(:,2),Pnt2(:,3));
% [X3,Y3]=STA.ternData(Pnt3(:,1),Pnt3(:,2),Pnt3(:,3));
% [ind1,~]=convhull([X1,Y1]);
% [ind2,~]=convhull([X2,Y2]);
% [ind3,~]=convhull([X3,Y3]);
%
% % 绘制凸包(Draw convhull)
% STA.SFill(Pnt1(ind1,1),Pnt1(ind1,2),Pnt1(ind1,3),[0.4,0.76,0.65],'FaceAlpha',.2,'LineWidth',2,'EdgeColor',[0.4,0.76,0.65]./2);
% STA.SFill(Pnt2(ind2,1),Pnt2(ind2,2),Pnt2(ind2,3),[1,0.55,0.38],'FaceAlpha',.2,'LineWidth',2,'EdgeColor',[1,0.55,0.38]./2);
% STA.SFill(Pnt3(ind3,1),Pnt3(ind3,2),Pnt3(ind3,3),[0.55,0.63,0.8],'FaceAlpha',.2,'LineWidth',2,'EdgeColor',[0.55,0.63,0.8]./2);
% 绘制凸包(Draw convhull)
STA.SConvhull(Pnt1(:,1),Pnt1(:,2),Pnt1(:,3),[0.4,0.76,0.65],'FaceAlpha',.2,'LineWidth',2,'EdgeColor',[0.4,0.76,0.65]./2);
STA.SConvhull(Pnt2(:,1),Pnt2(:,2),Pnt2(:,3),[1,0.55,0.38],'FaceAlpha',.2,'LineWidth',2,'EdgeColor',[1,0.55,0.38]./2);
STA.SConvhull(Pnt3(:,1),Pnt3(:,2),Pnt3(:,3),[0.55,0.63,0.8],'FaceAlpha',.2,'LineWidth',2,'EdgeColor',[0.55,0.63,0.8]./2);
% 绘制图例(Draw legend)
legend({'Data1','Data2','Data3','convex1','convex2','convex3'},'FontSize',14,'FontName','Cambria')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化