フィルターのクリア

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 件のコメント
KSSV
KSSV 2018 年 3 月 26 日
s = s(1:length(t)) ;

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

回答 (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 Center および File ExchangeMatched 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