フィルターのクリア

Error using plot Vectors must be the same length.

1 回表示 (過去 30 日間)
Sofiya
Sofiya 2024 年 3 月 1 日
コメント済み: Sofiya 2024 年 3 月 4 日
Create a signal consisting of two successive sine waves with frequencies of 10 Hz and 20 Hz and additive noise. Filter the signal with an adaptive selective filter and plot in one graphic window: 1) the initial signal; 2) filtered signal; 3) error signal.
fs = 200; N = 1000; t = (0:(N-1))/fs;
s1 = sin(2*pi*10*t); s2 = sin(2*pi*20*t);
s = [s1, s2]; v = 0.4*randn(size(s));
t = (0:(N-1))/fs;
x = s + v;
delay = 5; % затримка
xd = [x(delay:end), zeros(1,delay-1)];
L = 64; mu = 0.001;
[w, y, e] = lms(x, xd, mu, L);
figure(4)
subplot(311), plot(t, x), grid on
subplot(312), plot(t,y), grid on
N = 1000
subplot(313), plot(t,e), grid on
fprintf('var(e) = %4.3f\n',var(e))

回答 (1 件)

Walter Roberson
Walter Roberson 2024 年 3 月 1 日
t = (0:(N-1))/fs;
s1 = sin(2*pi*10*t); s2 = sin(2*pi*20*t);
s = [s1, s2];
s is a row vector that is twice as long as t (since it is two vectors put together, each the same size as t)
x = s + v;
x is the same size as s, so is twice as large as t
subplot(311), plot(t, x), grid on
there you try to plot t against x but x is twice as large as t.
  2 件のコメント
Walter Roberson
Walter Roberson 2024 年 3 月 1 日
Possibly you want the second assignment to t to be
t = (0:(size(s,2)-1))/fs;
Sofiya
Sofiya 2024 年 3 月 4 日
Thanks a million!!!

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

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by