Hello,
I am currently working on a project aimed at identifying a simple system. The project is divided into several steps:
1. **Simulate a continuous system** such as an RLC circuit.
2. **Discretize the associated transfer function**.
3. **Obtain the time-domain output \( y \)** using the `lsim` function in MATLAB.
4. **Add Gaussian noise** to the output samples.
5. **Estimate the coefficients** of the discretized transfer function using the Instrumental Variable (IV) method.
I’m encountering an issue with the last step. Each time I rerun the code in MATLAB, the coefficients I obtain vary significantly. To understand this behavior, I performed a Monte Carlo test to estimate the standard deviation of the coefficients across multiple trials. The results show that this standard deviation is quite large.
Typically, the IV method should decorrelate the noise from the output, allowing for a stable estimation of the coefficients. Therefore, it's puzzling to observe such large variations between tests.
Here’s an excerpt of the code I am using:
%% Discretization Parameters
Ts = 0.01; % Sampling period
t = 0:Ts:10; % Time vector
%% Monte Carlo Loop for Multiple Realizations
num_realizations = 100; % Number of Monte Carlo realizations
p = tf('s'); % Laplace variable
for i = 1:num_realizations
% Generation of PRBS Signal
u = idinput(length(t), 'prbs', [0, 1/7]); % PRBS with 7 level changes
% Transfer Function of the Series RLC Circuit
FT_RLC_circuit = 1 / (L*C*p^2 + R*C*p + 1);
% System Simulation
Y_RLC_MC = lsim(FT_RLC_circuit, u, t);
% Adding Gaussian Noise with a Given SNR
SNR = 15;
e = randn(size(Y_RLC_MC));
k = sqrt( (Y_RLC_MC'*Y_RLC_MC) / (e'*e)) * 10^(-SNR/20);
b = k * e;
Y_noisy = Y_RLC_MC + b;
% Model Identification Using Instrumental Variable Method (IV4)
Sys = iv4(u, Y_noisy, [2 2 1]); % Chosen orders [na nb nk]
% Extracting Numerator and Denominator Coefficients
[num_iv, den_iv] = tfdata(Sys, 'v');
% Saving the Coefficients in a Structure or File
results(i).numerator = num_iv;
results(i).denominator = den_iv;
end