09-06-2012 05:02 AM
I would like to obtain in Labview the same output as Matlab's decimate function.
I was expecting that MathScript's "decimate" function would do that but this doesn't seem to be the case.
To make comparison easier I will be using the decimate function with three parameters.
decimate(A,B,C)
Where
A = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]
B = 2
C = 8 (Chebyshev type I, 8th order filter)
Matlab returns:
1.2708
2.1873
3.2438
4.1731
5.2076
6.1679
7.1663
8.1662
9.1254
10.1559
11.1004
12.1261
13.0992
14.0648
15.1451
15.8024
Labview returns:
1.0
1.72746
2.75001
3.75001
4.75001
6.75001
7.75001
8.75001
9.75001
10.75
11.75
12.75
13.7495
14.7619
15.6993
Could anyone explain how to get from one to the other?
Regards,
09-11-2012 05:16 AM
Hi,
I'm an applications engineer at NIUK and I've been looking into this.
We don't have matlab, but I have reproduced the problem in mathscript. It seems that whats going on under the hood is slightly different between the two, as decimate is a high level function. Perhaps mathscript doesn't generate quite the same filter.
I took a look at the matlab help pages to see what the component functions are. By replicating these lower level functions in mathscript we can get the same output!
Assuming you have used A, B and C as before, you can use the following mathscript code:
[g,f]=iir_cheby1(C,0.05,0.8/B) y=filtfilt(g,f,A) z=downsample(y,b,b-1)
where z will give the desired output.
Line 1 generates a chebyshev type 1 filter of order C, with ripple 0.05 and cutoff 0.8/B.
Line 2 applies zero phase filtering.
Line 3 takes out every 'b'th element, starting at index b-1. (zero indexed array)
Please do test this out and compare to matlab, and keep me posted.
09-13-2012 04:45 AM
Ian,
Thanks for looking at this issue.
Our signal processing engineers use mainly Matlab but the products we make use LabVIEW.
I appreciate MathScript availability which allows for quick algorithm implementation.
We suspected the filtering to be different and your code snippet will help us validate LabVIEW code against Matlab scripts.
Regards,