transfer_functions.jl 336 Bytes
Newer Older
Fredrik Bagge Carlson's avatar
dev tf  
Fredrik Bagge Carlson committed
1
using DSP
Fredrik Bagge Carlson's avatar
Fredrik Bagge Carlson committed
2

Fredrik Bagge Carlson's avatar
Fredrik Bagge Carlson committed
3
4
5
6
7
8
"""
    tfest(y,u)

Estimate a transfer function model using the Correlogram approach
H = Syu/Suu
"""
Fredrik Bagge Carlson's avatar
dev tf  
Fredrik Bagge Carlson committed
9
10
11
12
13
function tfest(y,u)
    Cyu = xcorr(y,u)
    Cuu = xcorr(u,u)
    Syu = welch_pgram(Cyu)
    Suu = welch_pgram(Cuu)
Fredrik Bagge Carlson's avatar
Fredrik Bagge Carlson committed
14
    return H = TFdata(Syu.power./Suu.power,Syu.freq)
Fredrik Bagge Carlson's avatar
dev tf  
Fredrik Bagge Carlson committed
15
16
end

Fredrik Bagge Carlson's avatar
Fredrik Bagge Carlson committed
17
tfest(iddata::IdData) = tfest(iddata.y,iddata.u)