How to initialize the Hammerstein model linear block and avoiding that the nlhw function transform the linear block to polynomial form ?
4 次查看(过去 30 天)
显示 更早的评论
Hi.
I am trying to estiamte a Hammerstein Model. I have a state representation of the linear block to generate the Hammerstein model, however for some reason the idnlhw function convert the state representation that I have to polynomial form. The above should not be a problem, but the poles of linear block are close together due to the slow dynamcis of my system. From what i read in this post https://la.mathworks.com/help/control/ug/sensitivity-of-multiple-roots.html closelied space poles are very sensitivy to model transformaiton from state space to polynomial represntation.
The above becomes problematic because I want to program this model in a 32-bit microncontroller but this pole sensitivy changes the value of my poles when I convert them to single precision.
How can I solve this issue.
1 个评论
Rahul
2024-9-17
Hey @Erick Axel, can you attach the code you have tried yet, that will help better understand the issue.
回答(1 个)
Rahul
2024-9-17
Hi,
While using the “idnlhw” function to construct a Hammerstein-Weiner model object, a state-space linear model is probably implicitly converted to a transfer function, which causes the closely spaced poles to be altered by small margins, enough to cause instability in the system.
Although, this behavior cannot be altered due to floating point errors and storage, but you can try the below mentioned possible workaround:
- Specify Precision: Use double data type precision while defining state space matrices for the linear model before calling the ”idnlhw” function.
- Transfer Function: Instead of using “ss” function to construct the linear model as a state-space, you can use “ss2tf” function to create transfer function numerator and denominator polynomials for the model beforehand, create a transfer function using “tf” function and the obtained polynomials, and finally pass it to the ”idnlhw” function to create the Hammerstein model.Unlike using “ss” or “tf” functions, ”ss2tf” more accurately retains the transfer function coefficients of models with closely related poles or zerosand doesn’t enforce pole-zero cancellation as much. Thus, retaining most of the poles/zeros as obtained from the original state-space matrices.
The following code is an example of how you can achieve the same in MATLAB:
% Define state-space matrices for a discrete-time system
A = double([0.9 0.1;0 0.90001]);
B = double([1; 0]);
C = double([1 1]);
D = double(0);
% Create state-space system
sys_ss = idss(A, B, C, D);
% Convert state space to transfer function
[num, den] = ss2tf(A, B, C, D);
convsys_tf = tf(num, den, 1)
% Display poles and zeros of state space linear model
disp('Poles of State-Space System:');
disp(pole(sys_ss));
disp('Zeros:');
disp(zero(sys_ss));
% Display poles and zeros of converted transfer function of linear model
disp('Poles of Converted Transfer Function System:');
disp(pole(convsys_tf));
disp('Zeros:');
disp(zero(convsys_tf));
% Simulate the response
t = 0:1:100; % Time vector
u = ones(size(t)); % Input signal (step input)
[y1, t1, x1] = lsim(sys_ss, u, t);
[y2, t2, x2] = lsim(convsys_tf, u, t);
% Plot the response
figure;
plot(t1, y1);
hold on;
plot(t2, y2);
hold off;
xlabel('Time (s)');
ylabel('Output');
title('Response of the Discrete-Time System');
legend on
legend({'State Space Model', 'Converted transfer function'});
% Check Linear Models of idnlhw objects
hw_ss = idnlhw(sys_ss);
mdl_ss = hw_ss.LinearModel
hw_tf = idnlhw(convsys_tf);
mds_tf = hw_tf.LinearModel
For more information regarding usage of "ss2tf" function to generate transfer function polynomials in MATLAB, refer to the documentation link mentioned below:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Model Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!