0
Applying Filters to signals

have a signal file saved as a .CSV file. I read the file then plot the data, the file is time and voltage amplitude, time steps are .035 seconds, there are 514 data points. Now I want to apply a filter to the data that I have read into Scilab and plot filtered data. Below is what I'm doing for a filter and how I'm applying it. Error message is below the sample code. So what am I doing wrong, there are lots of examples showing filter response plots but hardly any showing how you apply them to data loaded from a file.

//data=csvRead(filename);
data1 = csvRead(filename1);

data=[data1];

x = data(:,1);
y = data(:,2);

Order   = 2; // The order of the filter
Fs      = 1000; // The sampling frequency
Fcutoff = 40;   // The cutoff frequency

hz = iir(Order,'lp','ellip',[Fcutoff/Fs/2 0],[0.1 0.1]);

sl= tf2ss(hz); // From transfert function to syslin representation
y_filtered = flts(y,sl); // Filter the signal

!--error 60
Wrong size for argument: Incompatible dimensions.
at line 12 of function flts called by :
y_filtered = flts(y,sl); // Filter the signal
at line 29 of exec file called by :
high pass filter.sce', -1


Scilab 28-03-19, 11:09 p.m. lgunseor
0

Your same code with a different input matrix works

Order   = 2; // The order of the filter
Fs      = 1000; // The sampling frequency
Fcutoff = 40;   // The cutoff frequency

hz = iir(Order,'lp','ellip',[Fcutoff/Fs/2 0],[0.1 0.1]);

sl= tf2ss(hz); // From transfert function to syslin representation
y_filtered = flts(0:10,sl);

plot(y_filtered)

So probably the problem liles in your input data matrix to flts. Check its size/length.

Rupak

26-12-19, 1 p.m. rupakrokade


Log-in to answer to this question.