+ Post New Thread
Results 1 to 3 of 3
-
8th June 2019, 12:56 #1
- Join Date
- Aug 2011
- Posts
- 197
- Helped
- 0 / 0
- Points
- 2,386
- Level
- 11
Why this Matlab code not work
I have an array(arry(k)) that contains the sampled waveform. All that I am trying to do is to subject the array data to 2nd order IIR HPF and store the result in another array. But I am getting error when running the matlab code. What could be the problem?
Code:b0=0.9693; b1=-1.9386; b2=0.9693; a1=-1.9381; a2=0.9390; for k=1:16 y=b0*arry(k)+b1*x1+b2*x2-a1*y1-a2*y2; y1=y; y2=y1; x2=x1; x1=arry(k); filt_arry(k)=y; end
Undefined function or variable 'x1'.
-
Advertisement
-
8th June 2019, 16:30 #2
- Join Date
- Nov 2006
- Location
- Brazil
- Posts
- 8,914
- Helped
- 1128 / 1128
- Points
- 29,856
- Level
- 42
- Blog Entries
- 9
Re: Why this Matlab code not work
You are using the 'x1' variable whth no previous assignment.
Provide an initial value prior getting in the for...end loop--------------------------------------------------------------------------------------------------
Part of the world that you live in, You are the part that you're giving ( Renaissance )
-
Advertisement
-
8th June 2019, 16:45 #3
- Join Date
- Aug 2011
- Posts
- 197
- Helped
- 0 / 0
- Points
- 2,386
- Level
- 11
Re: Why this Matlab code not work
Oh.. silly me. It works
+ Post New Thread
Please login