-
Notifications
You must be signed in to change notification settings - Fork 3
/
desired_function.m
72 lines (43 loc) · 1.34 KB
/
desired_function.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
function [out, lag, Rz] = desired_function(zk, Fk, Rz, N1, N2, Ts, entrada, signal, MAX_LAG,goal)
format long e
%N = length(signal);
entrada = glottal_model(entrada,N1,N2);
%zk=.999;
%Fk = 2;
T=Ts;
%V_z = Rz*tf([1 -1 zeros(1,2*length(zk)-1)],1,Ts);
V_z = Rz*tf([1 -1],[1 0],Ts);
Vk_z(1:length(zk)) = tf(0,1,Ts);
for i=1:length(zk)
Vk_z(i) = tf([(1-2*abs(zk(i))*cos(2*pi*Fk(i)*T)+abs(zk(i))^2) 0 0],[1 -2*abs(zk(i))*cos(2*pi*Fk(i)*T) abs(zk(i))^2],Ts);
V_z = V_z*Vk_z(i);
end
if isstable(V_z)
saida_calc = lsim(V_z,entrada);
else
saida_calc = zeros(1,length(signal));
end
Rz = max(signal)/max(saida_calc);
%RMSerror = sqrt(mean((saida_calc'-signal).^2)/mean((signal).^2));
%RMSerror = sqrt(mean((saida_calc'-signal).^2));
% aux_X =xcorr(saida_calc/max(saida_calc),signal/max(signal),MAX_LAG);
%
% [A, lag] = max(aux_X);
%
%
%
% out = [1/A mean(abs(aux_X))];
%disp(saida_calc')
%disp(signal)
aux_X = xcorr(saida_calc/max(saida_calc),signal/max(signal));
%aux_X = (signal/max(signal))*(saida_calc/max(saida_calc));
%aux_X =conv(saida_calc,signal);
A = max(aux_X);
%A = aux_X;
lag=0;
%out = ([1/A]);
out = (goal*A);
%A = 100*(1-norm(signal-saida_calc')/norm(signal-mean(signal)));
%out = abs([1/A]);
%out = mean(abs(((saida_calc/aux_a)'./((signal/aux_b)+1e-15)-1)));
%out = mean(abs(((saida_calc/aux_a)'-signal/aux_b)));