Is there a typo in the documentation for n4sid?
3 ビュー (過去 30 日間)
古いコメントを表示
The documentation for n4sid contains the following code snippet. I believe the line u(k-1) = -K*y(k-2) + w(k); should read u(k-2) = -K*y(k-2) + w(k);.
N = 1000;
K = 0.5;
rng('default');
w = randn(N,1);
z = zeros(N,1);
u = zeros(N,1);
y = zeros(N,1);
e = randn(N,1);
v = filter([1 0.5],[1 1.5 0.7],e);
for k = 3:N
u(k-1) = -K*y(k-2) + w(k);
u(k-1) = -K*y(k-1) + w(k);
z(k) = 1.5*z(k-1) - 0.7*z(k-2) + u(k-1) + 0.5*u(k-2);
y(k) = z(k) + 0.8*v(k);
end
dat = iddata(y, u, 1);
0 件のコメント
採用された回答
Anjaneyulu Bairi
2025 年 1 月 11 日
Hi,
The first line in for loop should not be u(k-1). It should be u(k-2).
Please use below code to generate close loop data.
N = 1000;
K = 0.5;
rng('default');
w = randn(N,1);
z = zeros(N,1);
u = zeros(N,1);
y = zeros(N,1);
e = randn(N,1);
v = filter([1 0.5],[1 1.5 0.7],e);
for k = 3:N
u(k-2) = -K*y(k-2) + w(k-2);
u(k-1) = -K*y(k-1) + w(k-1);
z(k) = 1.5*z(k-1) - 0.7*z(k-2) + u(k-1) + 0.5*u(k-2);
y(k) = z(k) + 0.8*v(k);
end
dat = iddata(y, u, 1);
Hope it helps!
2 件のコメント
Steven Lord
2025 年 1 月 13 日
Please contact Technical Support directly using this link rather than simply waiting and hoping it is seen by Technical Support. [Yes, I am a MathWorks staff member. But no, I am not familiar with System Identification Toolbox and so cannot answer the question.]
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!