필터 지우기
필터 지우기

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 CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by