필터 지우기
필터 지우기

why i'm getting this error?

조회 수: 1 (최근 30일)
ocsse
ocsse 2018년 3월 26일
답변: Prajith Chilummula 2018년 4월 5일
why i'm getting Vectors must be the same length? for an and bn. can someone explain the error also? i always make this mistake
samples = 500;
T = 5;
f0 = 1/T;
t = 0:(1/(samples*f0)):T; % 5 cycles
s = exp((10 - t) / 2);
n = 1:3;
N = 5;
s = repmat(s, [1 N]);
t = 0:(1/(samples*f0)):N*T;
figure()
hold on
plot(t, s)
grid on
a0 = (1/T) * sum(s);
an = (2/T) * s * cos(2*pi*f0*n*t);
bn = (2/T) * s * sin(2*pi*f0*n*t);
thanks

답변 (1개)

Prajith Chilummula
Prajith Chilummula 2018년 4월 5일
Hi ocsse,
The line below produces a vector of size 501.
t = 0:(1/(samples*f0)):T;
repmat repeats the 1X501 matrix 5 times along the row making it 1X2505 size vector.So s has 1X2505 dimension.
s = repmat(s, [1 N]);
The line below produces a vector of dimension 1X2501.
t = 0:(1/(samples*f0)):N*T;
So there is mismatch in sizes of s and t.Therefore you get the error mentioned.

카테고리

Help CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by