I am trying to filter audio using lms filter but i got this error"Error using filter Invalid data type. Input arrays must be numeric or logical".

4 vues (au cours des 30 derniers jours)
i am using adaptive filter to cancel the background noise from the signal but when i apply the signal it show the error ,"Input arrays must be numeric or logical".Please help me solve this problem
The code is as folows:
[NB: formatted code for legibility -- dpb ]
[filename,path]=uigetfile('*.*');
[y,Fs]=audioread(filename);%loads voice signal
sound(y,Fs)
pause(6)
d=awgn(y,11);%Voice signal contaminated with 10.5dB AWGN
sound(d,Fs)
k=length(y);%Length of the voice signal
t=1/Fs:1/Fs:1/Fs*k;%Time range and incremental value
figure(1)
subplot(1,2,1);
plot(t,y);%plots original voice signal in black
grid on
ylabel('Amplitude in Volts')
xlabel('Time in Sec.')
subplot(1,2,2)
plot(t,d,'k');%plots contaminated voice signal in black
grid on
ylabel('Amplitude in Volts')
xlabel('Time in Sec.')
L=32;%Order of the filter
mu=0.0002;%Step size for the adaptation process
% introduced bold by OP here -- dpb
ha=dsp.LMSFilter('Length',L+1,'StepSize',mu);
[y1,e]=filter(ha,y,d);%Filters the voice signal
% to here...
pause(2)
sound(y1,Fs)

Réponse acceptée

dpb
dpb le 22 Mai 2022
Modifié(e) : dpb le 23 Mai 2022
I don't have the DSP TB, but looking at the doc, the intro page has
To filter a signal using an adaptive FIR filter:
  1. Create the dsp.LMSFilter object and set its properties.
  2. Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?
The example returns an object from the call as (using your variables above in place of exact example)
lmsfilt = dsp.LMSFilter('Length',L+1,'StepSize',mu);
[y1,e] = lmsfilt(y,d);
As it says, they called the object returned as a function instead of calling a standalone function as you did.
I don't know what filter will resolve to on a system with the DSP TB installed; here w/o it but w/ the Signal Processing TB instead, I still get the builtin filter function which expects the input filter coefficients and signal all as doubles; the error message you get is consistent with passing an object handle to it as you did.
I have no idea if the above will work as you intend, but I believe that is the way to use the DSP filter object. Looks like could be a steep learning curve there as it is implemented embedded in the objects.

Plus de réponses (0)

Produits


Version

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by