LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview equivalent to matlab filter function

Hi

 

I have a script In Matlab that is using the built-in filter function in matlab.

 

y = filter(B,A,x);

 

were x is the signal to be filtered and A/B is the filter coefficients.

 

Is there a labview function that gives my the same y as Matlab does if x, A and B is the same.

 

Best wishes 

0 Kudos
Message 1 of 7
(5,200 Views)
Try Signal Processing -> Filters palette. Also you could try using MatScript node (MathScript module required) for the Matlab commands implemented in LabVIEW directly.
---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... 🙂

Chart zoom with "Mouse Over" effect
0 Kudos
Message 2 of 7
(5,197 Views)
I have tried the IIR Filter and used A as reverse coefficient and B as forward cofficients with no luck.
0 Kudos
Message 3 of 7
(5,181 Views)
'No luck' is a pretty poor description of a problem. Provide some details. Attach your VI with data and explain exactly what you expect and how it is different than what you are seeing.
0 Kudos
Message 4 of 7
(5,173 Views)

🙂 sorry. I post some Matlab code and VI to demonstrate.

 

Matlab code:

clear;

 

x = 1:12;

A = [1 2 1 1];

B = [1 1 2 1];

y = filter(B,A,x)

 

%y =

%

%     1     1     4     2     8     0    17   -10    40   -45   107  -157

%

y2 = filter(B,A,x, [0 1 0]')

%y2 =

%

%     1     2     2     5     3     9     1    18    -9    41   -44   108

 

 

 and my VI is attached (screenshot). My Y is correct to the first filter call to matlab (y = y in both lw and matlab). And that is good. But the other call use a the vector Zi = [0 1 0] and from Matlabs help

 

 

[Y,Zf] = FILTER(B,A,X,Zi) gives access to initial and final

    conditions, Zi and Zf, of the delays.  Zi is 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.

 

 

Any idees how this can be done in LabView or what the Zi does in the Matlab implementation?

 

 

 

Message Edited by Tudor on 02-11-2010 09:29 AM
0 Kudos
Message 5 of 7
(5,165 Views)
I tried to run the matlab function filtfilt from LabView but it gives me some edge effects. Doesnt lw MathScript Node use matlab to compute? See my attached screenshot of my vi, matlab .m script and the result plots. Im using the same data and the same script in both matlab and labview.
0 Kudos
Message 6 of 7
(5,124 Views)
Let's follow the MathScript filtfilt discussion in this thread.
0 Kudos
Message 7 of 7
(5,056 Views)