Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Archivos temporales de matlab
*.m~
26 changes: 23 additions & 3 deletions identification_methods.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
%% Identifico por minimos cuadrados en forma recursiva
plot_ident = true;
Gzi_mc = discrete_ident_recursive_least_squares(data_ident, Ts, plot_ident)

%% Validacion de resultados
validate_identifications(data_test, Gzi, Gzi_mc)

Expand All @@ -50,6 +49,7 @@
%# OUTPUT noisy (simbólico) señal con ruido agregado
%#

noiseSignal = awgn (clean_signal, snr)

end

Expand All @@ -61,7 +61,11 @@
%# INPUT output_signal (double-sym) la señal de salida
%# INPUT sample_time (double) tiempo de muestreo
%# OUTPUT [data_ident(iddata), data_validation(iddata)]

% Armo el paquete de datos
N1 = floor(N/2);
data = iddata(y, u, Ts);
data_ident = data(1:N1);
data_test = data(N1+1:N);
end

function Gzi = discrete_ident_arx(data, Ts, focus_mode, na, nb, nk, residual_analysis)
Expand All @@ -88,7 +92,22 @@
%# INPUT Ts(double): tiempo de muestreo
%# INPUT plot_ident(logical): opción de plotear la identificación
%# OUTPUT Gzi_mc(tf): función de transferencia identificada


N1=plot_ident;
%prueba
n = 3;
u = data.InputData;
y = data.OutputData;
Theta = zeros(4, N1);
P = 1e12*eye(4);

for k = n:N1-1
Phi = [-y(k-1) -y(k-2) u(k-1) u(k-2)];
K = P*Phi'/(1+(Phi*P*Phi'));
Theta(:,k+1) = Theta(:,k)+K*(y(k)-Phi*Theta(:,k));
P = P-(K*Phi*P);
end
Gzi_mc = tf(Theta(3:4,N1)', [1 Theta(1:2,N1)'], Ts)
end

function analyze_residuals(data, sys_id, sampling_frequency)
Expand All @@ -101,6 +120,7 @@ function analyze_residuals(data, sys_id, sampling_frequency)

end


function validate_identifications(data, Gzi, Gzi_mc)
%#VALIDATE_IDENTIFICATIONS
%#
Expand Down