Getting a filter error today when yesterday didn't?
3 ビュー (過去 30 日間)
古いコメントを表示
Is MATLAB a time varying system? Everything was working swimmingly for me yesterday, but I'm riddled with errors today, for code that has been unchanged since written yesterday.
For reference, I'm getting: Error using filter Initial conditions must be a vector of length max(length(a),length(b))-1, or an array with the leading dimension of size max(length(a),length(b))-1 and with remaining dimensions matching those of x.
I was able to get the stem plot associated with it from yesterday, and I know that this is what it's supposed to look like, indicating that it was written correctly:
Using the code:
tmin = 0;
tmax = 0.1;
dt = 1/2000;
t = tmin:dt:tmax;
x = 3*cos(2*pi*30*t) + cos(2*pi*200*t);
n = 79;
d = [1 zeros(1,n)];
a = [1 -1.294 0.64];
b = [1.812 -2.932 1.812];
q = filter(b,a,d,x);
stem(q)
0 件のコメント
回答 (1 件)
Chad Greene
2021 年 4 月 28 日
I suspect that yesterday you weren't including x in the filter. Yesterday you were filtering the d signal, which is just [1 0 0 0 0 ... 0]. When you filter d, all you're left with is the ringing from the impulse.
tmin = 0;
tmax = 0.1;
dt = 1/2000;
t = tmin:dt:tmax;
x = 3*cos(2*pi*30*t) + cos(2*pi*200*t);
n = 79;
d = [1 zeros(1,n)];
a = [1 -1.294 0.64];
b = [1.812 -2.932 1.812];
q = filter(b,a,d);
stem(q)
Were you intending instead to filter x?
q = filter(b,a,x);
stem(q)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Filter Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!