I get Vectors must be the same length. error

3 ビュー (過去 30 日間)
adrixas
adrixas 2017 年 4 月 12 日
回答済み: Star Strider 2017 年 4 月 12 日
Hello, maybe someone know why I get this error?
F=1000;
Fn=F/2;
f=[0:20:160 180 200 220 240:20:500] ;
am=[ones(1,9) 0.9 0.5 0.1 zeros(1,14)];
fn=f/Fn;
N=32;
a=1;
b=firls(N, fn, am);
H=freqz(b, a, 1000);
w=hamming(N);
figure(2);
plot(w*Fn/pi, abs(H));
Thanks in advance
  2 件のコメント
Jan
Jan 2017 年 4 月 12 日
I've edited the code today. Please use the "{} Code" button the next time. Thanks.
Manashee Malita
Manashee Malita 2017 年 4 月 12 日
For the function "plot(x,y)", if x and y are some vector or matrix, they must have same length or size. If you assume x=w*Fn/pi and y=abs(H), then you can observe that the size of x and y are different. Regards M.Kalita

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

回答 (1 件)

Star Strider
Star Strider 2017 年 4 月 12 日
Request 2 outputs from your freqz call, rather than creating your own frequency vector:
[H,w]=freqz(b, a, 1000);
figure(2);
plot(w, abs(H));

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by