I'm working in R with the packages signal
and control
(don't know wether these are even the best for my use case).
I have a high pass filter (butterworth, of order 1, some chosen cutoff frequency) and a (onedimensional) signal $s$.
I would like to filter $s$ using my high pass filter in a way, that pretends, that my high pass filter has previously seen the input $s[0]$ for an infinite amount of time.
I got a Python script, that does this using functions from the package signal
. The procedure is as follows:
- Create the filter (in tf-representation)
- Switch to state space representation Calculate the initial condition for the state vector
- Pass the filter, the input, the initial condition for the state vector to the function
lsim2
of Python'ssignal
package. - There you have the results
In R I can accomplish all but the second to last step.
Using the lsim
function of control
package doe not give the same results as in the Python scripts. I also tried the filter
function from the package signal
but this doesn't seem to allow me to provide an initial condition for the state space vectors.
Any hints on how to achieve this would be greatly appreciated.
I'm coming over from math.stackexchange so this is my first question. Please be gentle, if due to my lack of experience here, the question is not perfectly posed.
Thanks in advance!