-
Notifications
You must be signed in to change notification settings - Fork 5
/
pwa_plot.m
77 lines (76 loc) · 2.43 KB
/
pwa_plot.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
function pwa_plot(pwasys)
if size(pwasys.X,2)==1,
figure(20);
plot(pwasys.X,pwasys.Y);
title('PWA Approximation');
xlabel('xNL');
figure(30);
nm = sqrt(length(pwasys.W));
plot(pwasys.W,pwasys.Z);
title('Nonlinear Function');
xlabel('xNL');
figure(40);
plot(pwasys.W,pwasys.Err);
title('Approximation Error');
xlabel('xNL');
elseif size(pwasys.X,2)==2 && size(pwasys.Y,2)==1,
figure(10);
triplot(pwasys.T,pwasys.X(:,1),pwasys.X(:,2));
title('Polytopic Regions');
xlabel('x_1');
ylabel('x_2');
figure(20);
trimesh(pwasys.T,pwasys.X(:,1),pwasys.X(:,2),pwasys.Y);
title('PWA Approximation');
xlabel('x_1');
ylabel('x_2');
figure(30);
nm = sqrt(length(pwasys.W));
surface(reshape(pwasys.W(:,1),nm,nm),reshape(pwasys.W(:,2),nm,nm),reshape(pwasys.Z,nm,nm));
title('Nonlinear Function');
xlabel('x_1');
ylabel('x_2');
figure(40);
mesh(reshape(pwasys.W(:,1),nm,nm),reshape(pwasys.W(:,2),nm,nm),reshape(pwasys.Err,nm,nm));
title('Approximation Error');
xlabel('x_1');
ylabel('x_2');
elseif size(pwasys.X,2)==2 && size(pwasys.Y,2)==2,
figure(10);
triplot(pwasys.T,pwasys.X(:,1),pwasys.X(:,2));
title('Polytopic Regions');
xlabel('x_1');
ylabel('x_2');
figure(20);
trimesh(pwasys.T,pwasys.X(:,1),pwasys.X(:,2),pwasys.Y(:,1));
title('PWA Approximation');
xlabel('x_1');
ylabel('x_2');
figure(25);
trimesh(pwasys.T,pwasys.X(:,1),pwasys.X(:,2),pwasys.Y(:,2));
title('PWA Approximation');
xlabel('x_1');
ylabel('x_2');
figure(30);
nm = sqrt(length(pwasys.W));
mesh(reshape(pwasys.W(:,1),nm,nm),reshape(pwasys.W(:,2),nm,nm),reshape(pwasys.Z(:,1),nm,nm));
title('Nonlinear Function');
xlabel('x_1');
ylabel('x_2');
figure(35);
nm = sqrt(length(pwasys.W));
mesh(reshape(pwasys.W(:,1),nm,nm),reshape(pwasys.W(:,2),nm,nm),reshape(pwasys.Z(:,2),nm,nm));
title('Nonlinear Function');
xlabel('x_1');
ylabel('x_2');
figure(40);
mesh(reshape(pwasys.W(:,1),nm,nm),reshape(pwasys.W(:,2),nm,nm),reshape(pwasys.Err(:,1),nm,nm));
title('Approximation Error');
xlabel('x_1');
ylabel('x_2');
figure(45);
mesh(reshape(pwasys.W(:,1),nm,nm),reshape(pwasys.W(:,2),nm,nm),reshape(pwasys.Err(:,2),nm,nm));
title('Approximation Error');
xlabel('x_1');
ylabel('x_2');
end