How to set initial conditions of a Hammerstein Model without using the compare function?

4 次查看(过去 30 天)
I am trying to fit the Hammerstein Model, but determining appropiate initial conditions without the use of the compare function of matlab is very difficult since if a try to set them naully the system diverges greatly from the actual measure data.

回答(1 个)

Umar
Umar 2024-8-28

Hi @Erick Axel ,

To address your query regarding, “I am trying to fit the Hammerstein Model, but determining appropiate initial conditions without the use of the compare function of matlab is very difficult since if a try to set them naully the system diverges greatly from the actual measure data. “

Please see my response to your comments below.

Fitting a Hammerstein model can indeed be a complex task, especially when it comes to selecting initial conditions that lead to convergence of the model parameters. The provided code below offers a structured approach to tackle this problem by generating synthetic data and utilizing the nlhw function for model fitting.

% Step 1: Generate Random Data
% Define the random seed for reproducibility
rng(1); 
% Generate input data (u) and output data (y)
N = 1000; % Number of samples
u = randn(N, 1); % Random input signal
% Simulate a nonlinear system with some noise
y = 2 * (u.^2) + 0.5 * randn(N, 1); % Nonlinear output with noise
% Create an iddata object for system identification
data = iddata(y, u, 1); % 1 second sampling time
% Step 2: Define Model Orders
Orders = [2 2 0]; % [na nb nk] where na is the order of the output, nb is the     
order of the input, and nk is the input delay
% Step 3: Fit the Hammerstein-Wiener Model
% Using default piecewise linear functions for nonlinearity
sys = nlhw(data, Orders);
% Step 4: Display Results
% Compare the estimated model with the measured data
figure;
compare(data, sys);
title('Comparison of Measured Data and Estimated Hammerstein-Wiener   
Model');
% Display the estimated model parameters
disp('Estimated Model Parameters:');
disp(sys);

Please see attached.

So, this code demonstrates a systematic approach to fitting a Hammerstein-Wiener model using generated random data. By defining the input and output data, the code creates an iddata object, which is essential for system identification. The model orders are specified, allowing the nlhw function to estimate the model parameters effectively. To address the challenge of determining appropriate initial conditions, the code utilizes default settings for the nonlinearities, which can help stabilize the fitting process. This approach minimizes the risk of divergence from the actual measured data, as it avoids the pitfalls of manual adjustments. Although the compare function is not used, the model's performance can still be evaluated through visual inspection of the results displayed in the figure. This method provides a robust alternative for users facing difficulties with initial conditions in Hammerstein model fitting.

Here’s a key snippet from the code for clarity:

sys = nlhw(data, Orders);

This line is crucial as it fits the model based on the defined data and orders, to make sure about a more reliable estimation without manual intervention.

For more information regarding “nlhw” function, please refer to

https://www.mathworks.com/help/ident/ref/nlhw.html

Also, for more guidance about “Available Nonlinearity Estimators for Hammerstein-Wiener Models”, please refer to

https://www.mathworks.com/help/ident/ug/nonlinearity-estimators-for-hammerstein-wiener-models.html

Hope, this answers your question. Please let me know if you have any further questions.

类别

Help CenterFile Exchange 中查找有关 Linear Model Identification 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by