matlab中流行病模型的系统识别

时间:2015-04-09 10:59:18

标签: matlab system-identification

我正在尝试使用系统识别工具箱估算参数。我使用了文档中提供的三个生态系统的例子,并开发了它来构建我自己的模型。

这是我的模特:

> function [dx, y] = shigella(t, u, x,a,b,q,m,r,varargin)
> 
> y = [x(1); x(2); x(3)];
> 
> dx = [q - m*x(1) - b*x(1)*x(2) + a*x(3); (b*x(1)) - (m+r)*x(2); (r*x(2)) - (m+a)*x(3)];

系统ID代码:

FileName      = 'shigella';              % File describing the model structure.
Order         = [3 0 3];                % Model orders [ny nu nx].
Parameters    = struct('Name',    {'Loss of immunity', 'infectivity rate', 'population renewal', 'death rate', 'recovery rate'}, ...
   'Unit',    {'1/week' '1/week' '1/week' '1/week', '1/week'},                    ...
   'Value',   {0.25 0.002 10 0.012 0.14},                                        ...
   'Minimum', {-Inf -Inf -Inf -Inf -Inf},                                    ...
   'Maximum', {Inf Inf Inf Inf Inf},                                        ...
   'Fixed',   {false false false false false});   % Estimate all 4 parameters.
InitialStates = struct('Name', {'Susceptible', 'Infected', 'Recovered'}, ...
   'Unit',    {'Size (in thousands)' 'Size (in thousands)', 'Size(inthousands)'},     ...
   'Value',   {20 5 10},                                         ...
   'Minimum', {0 0 0},                                             ...
   'Maximum', {Inf Inf Inf},                                         ...
   'Fixed',   {false false false});   % Estimate both initial states.
Ts            = 0;                      % Time-continuous system.
nlgr = idnlgrey(FileName,Order, Parameters, InitialStates, Ts,                  ...
   'Name', 'Population Variation',               ...
   'OutputName', {'Susceptible', 'Infected', 'Recovered'}, ...
   'OutputUnit', {'Size (in thousands)' 'Size (in thousands)', 'Size (in thousands)'},     ...
   'TimeUnit', 'week');
present(nlgr)

w = [1000 5 0];
u = [80 15 3];
v = [65 24 10];
f = [90 27 8];
z = [87 20 10];
g = [w; u; v; f; z];

z = iddata(g,[], 1, 'Name', 'Population Variation');
set(z, 'OutputName', {'Susceptible', 'Infected', 'Recovered'}, ...
   'Tstart', 0, 'TimeUnit', 'Week');

compare(z, nlgr, 1)

opt = nlgreyestOptions;
opt.Display = 'on';
opt.SearchOption.MaxIter = 50;
nlgr = nlgreyest(nlgr, opt);

disp('   True      Estimated parameter vector');
ptrue = [0.25 0.002 10 0.012 0.14];
fprintf('   %6.3f    %6.3f\n', [ptrue'; getpvec(nlgr)']);
disp(' ');
disp('   True      Estimated initial states');
x0true = [20 5 10];
fprintf('   %6.3f    %6.3f\n', [x0true'; cell2mat(getinit(nlgr, 'Value'))']);

当我逐部分运行代码时,我收到以下错误:

???使用==>时出错idnlgrey.isvalid at 165错误或指定的ODE文件'shigella'不匹配。错误消息是:'尝试访问x(1);索引越界,因为numel(x)= 0。'

我试图摆脱比较部分并继续前进,但我得到了这个错误

???未定义的函数或变量'nlgreyestOptions'。


我真的很感激我能得到的任何帮助。

0 个答案:

没有答案