define an equation on Matlab

20 ビュー (過去 30 日間)
Hosein Haji Esmaeeli
Hosein Haji Esmaeeli 2020 年 12 月 2 日
Hi
there is an equation like this for my project
I really can't define it
so this is my equation:
y(t)+y(t-1)+y(t-2)=u(t-1)+u(t-2)+e(t)
that y(t) is output
u(t) is input
& e(t) is error
thanx

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 12 月 2 日
This is a difference equation. Simplest way is to use a for-loop
u = ones(100, 1); % using constant input;
e = rand(101, 1); % generating a random error vector
y = zeros(101, 1); % pre-allocating output vector
y(1) = 0;
y(2) = 0; % initial conditions
for t = 3:numel(y)
y(t) = u(t-1)+u(t-2)+e(t)-y(t-1)-y(t-2);
end
  1 件のコメント
Hosein Haji Esmaeeli
Hosein Haji Esmaeeli 2020 年 12 月 2 日
thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by