Getting a filter error today when yesterday didn't?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Chad Greene
am 28 Apr. 2021
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 Kommentare
Siehe auch
Kategorien
Mehr zu Filter Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!