-
Notifications
You must be signed in to change notification settings - Fork 9
/
TestAccuracyForward.m
37 lines (32 loc) · 1.38 KB
/
TestAccuracyForward.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
function [delta, test] = ...
TestAccuracyForward(num_train, data, Xp, Xq, Xp_dlpf, Xq_dlpf, B)
% this function test the accuracy of forward regression
%% calculate the results by data-driven linearized equations
for i = 1:num_train
test.p.fitting(i, :) = [data.Va(i,:) * pi / 180 data.V(i,:) 1] * Xp';
test.p.dcpf(i, :) = B * data.Va(i, :)' * pi / 180;
test.p.dlpf(i, :) = [data.Va(i,:) * pi / 180 data.V(i,:)]*Xp_dlpf';
test.q.fitting(i, :) = [data.Va(i,:) * pi / 180 data.V(i,:) 1]*Xq';
test.q.dlpf(i, :) = [data.Va(i,:) * pi / 180 data.V(i,:)]*Xq_dlpf';
end
%% calculate the errors, note that the value of nan or inf is removed
temp = abs((data.P - test.p.fitting)./data.P);
temp(find(isnan(temp)==1)) = [];
temp(find(isinf(temp)==1)) = [];
delta.p.fitting = mean(mean(temp)) * 100;
temp = abs((data.P - test.p.dcpf)./data.P);
temp(find(isnan(temp)==1)) = [];
temp(find(isinf(temp)==1)) = [];
delta.p.dcpf = mean(mean(temp)) * 100;
temp = abs((data.P - test.p.dlpf)./data.P);
temp(find(isnan(temp)==1)) = [];
temp(find(isinf(temp)==1)) = [];
delta.p.dlpf = mean(mean(temp)) * 100;
temp = abs((data.Q - test.q.fitting)./data.Q);
temp(find(isnan(temp)==1)) = [];
temp(find(isinf(temp)==1)) = [];
delta.q.fitting = mean(mean(temp)) * 100;
temp = abs((data.Q - test.q.dlpf)./data.Q);
temp(find(isnan(temp)==1)) = [];
temp(find(isinf(temp)==1)) = [];
delta.q.dlpf = mean(mean(temp)) * 100;