
LSIM initial value for RC filter doesnt work
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I would simulate an RC (low-pass) filter that has some initial value.
R = 1e3; % 1kOm
C = 100e-6; % 100uF
es = tf('s');
LP1 = 1 / (R*C*es + 1);
Ts = 0.1; % 100ms
sysd = c2d(LP1, Ts);
Initial value means that capacitor is charged to some voltage (lets say 5V) and we apply some voltage to the input (lets say 10V). I would see output voltage / time plot:
x0 = 5; % 5V
input = 10; % 10V
N = 100;
lsim(sysd, ones(1, N)*input, [], x0);
Plot that is showed starts with zero (no initial condition). If i convert tf to ss:
lsim(ss(sysd), ones(1, N)*input, [], x0);
Than plot starts from non zero value but it is NOT 5V that I set as initial value.

What is wrong with it, How to simulate it?
0 Commenti
Risposte (1)
Chris Setiadi
il 6 Set 2019
Hi Mike,
Since you transform your transfer function into state space formulation:
Recall that, in state - space form your state is not necessarily the same as the output. Given the model that you provide, the state to output relation is given as (the result of ss(sysd)) :
When you set the initial condition as 5, then it translates into an initial voltage of 3.1605, which is the same result that you have in the figure.
To simulate an initial "output" of 5 or any arbitrary value, you can of course use the state to output relation again and find the initial state. In this case x0 = 7.9099 should give you 5 V. A simple modification to your script should give you the result that you want:
x0 = 5/ss(sysd).C; % 5V
input = 10; % 10V
N = 100;
lsim(ss(sysd), ones(1, N)*input, [], x0);

Hope this helps, Good luck!
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!