Possible bug in fixed-step ODE solver in idnlgrey

1 次查看(过去 30 天)
I believe i have found a bug in the 'sim' function when simulating udnlgrey models using the fixed-step solvers. The fault is reproduced using a build-in example in the code below.
The fault result in a identical zero result for the last output of a simulation for certain step-sizes. I believe that the error result when the sim produce the 'tspan' for the odeX solvers. However, I have been unable to confirm this becuase i do not have access to the code calculating the tspan.
Has anyone experinced similar bugs?
Update: I found another potential bug in the ODE fixed-step solver for the idgrey structure. In the attached figure 'simResponds.fig' is the responds for a system simulated using the 'ode5' option and the 'auto' option displayed. The figure show that the fixed-step solver apply the control input 1 sample before the input is actual applied.
clear
clc
% Define system
FileName = 'dcmotor_m'; % File describing the model structure.
Order = [2 1 2]; % Model orders [ny nu nx].
Parameters = [1; 0.28]; % Initial parameters. Np = 2.
InitialStates = [0.5; 0.1]; % Initial initial states.
Ts = 0; % Time-continuous system.
nlgr = idnlgrey(FileName, Order, Parameters, InitialStates, Ts, ...
'Name', 'DC-motor');
% Define data
%############## Test case #############################
dt = 3.6836e-05; % <-- Lack last measurememt
%dt = 3.6835e-05; % <-- Do not lack last measurement
%######################################################
N = 100;
u_t = zeros([N 1]);
z_sim = iddata([],u_t,dt);
z_sim.Tstart = 0;
% Setup simulation
nlgr.SimulationOptions.Solver='ode5';
nlgr.SimulationOptions.FixedStep=dt;
opt = simOptions;
z_nlgrey = sim(nlgr,z_sim,opt);
z_nlgrey.Ts=dt;
plot(z_nlgrey)
z_nlgrey.y(end-1:end,1:2) %<--- Last set of points are unset
ans = 2×2
0.5004 0.0996 0 0

回答(0 个)

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by