from Discrete Transfer Function Identification of a Motor by Srikanthan Krishnan
Determining Discrete Transfer Function of a system

Find_Parameters(W,V,Fs,n)
function [Num, Den] = Find_Parameters(W,V,Fs,n)

% Author: K.Srikanthan
% Hardware and Systems Group - Automotive MBD
% Tata Elxsi Limited
%
% n - order of the system
% Fs - Sampling frequency
% W - output of the actual system
% V - input to the system


% clear all;
Ts = 1/Fs; % 1/1000; % Sampling interval
T = length(W)/Fs; % Duration of recording

Tw = (T-(2*n+1)/Fs); % Size of time window
m = round(Tw/Ts); % Size of time window interms of number of samples
% n = 2 % order of the sysem or number of poles - all pole system assumed

for i = m:-1:1
    for j = 1:(n)
        Q(m-i+1,j) = W((n+1)+i-j);
    end
    Vk(m-i+1) = V(i+(n+1));
    Wk(m-i+1) = W(i+(n+1));
end

X = [Q Vk'];
A = (X'*X)^-1*X'*Wk';
A1 = A';
Num = [A1(end) zeros(1:n)];
Den = [1 -A1(1:n)];

Contact us at files@mathworks.com