-
Notifications
You must be signed in to change notification settings - Fork 15
/
terndemo.m
77 lines (70 loc) · 1.5 KB
/
terndemo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
%% Simple two-d plot
dataA = linspace(0.1, 0.7, 20);
dataB = -dataA.^2 + dataA + (rand(size(dataA)) - 0.5)/7;
dataC = 1 - dataA - dataB;
A = linspace(0, 1, 100);
B = -A.^2+A;
ternplot(dataA, dataB, dataC, 'r.', 'majors', 5);
hold on
ternplot(A, B)
ternlabel('A', 'B', 'C')
legend('Data', 'Fit')
hold off
%% Simple two-d density plot
num_axes_steps = 5;
num_color_classes = 5;
ternplot_pro(dataA, dataB, dataC, num_axes_steps, num_color_classes);
ternlabel('A', 'B', 'C');
hold on
ternplot(dataA, dataB, dataC, 'r.');
hold off
%% Three D plot for viscosity of HIPS, ABS and PETG polymer blends
experimental = [...
1.000 0.000 0.000
0.000 1.000 0.000
0.000 0.000 1.000
0.500 0.500 0.000
0.500 0.000 0.500
0.000 0.500 0.500
0.333 0.333 0.333
0.750 0.250 0.000
0.250 0.750 0.000
0.750 0.000 0.250
0.250 0.000 0.750
0.000 0.750 0.250
0.000 0.250 0.750
0.667 0.167 0.167
0.167 0.667 0.167
0.167 0.167 0.667
0.000 0.900 0.100];
data = [...
0.139
0.373
0.089
0.151
0.056
0.679
0.095
0.153
0.178
0.084
0.040
0.463
0.163
0.111
0.170
0.072
0.333];
A = experimental(:, 1)';
B = experimental(:, 2)';
C = 1 - (A + B);
figure
subplot(2, 2, 1)
ternplot(A, B, C, '.'); ternlabel('HIPS', 'ABS', 'PETG');
subplot(2, 2, 2)
ternpcolor(A, B, data); ternlabel('HIPS', 'ABS', 'PETG');
shading interp
subplot(2, 2, 3)
terncontour(A, B, data); ternlabel('HIPS', 'ABS', 'PETG');
subplot(2, 2, 4)
ternsurf(A, B, data);