How can I calculate the SNR of a curve that has impulse noise added?

38 views Asked by At

I have an issue where I'm not sure how to calulate the SNR of a signal that I have in MATLAB. I have a real-world signal dataset that is a curve shape (a bit like a logarithmic curve) that I import into MATLAB from a .CSV. This is my reference curve. I then add impulse noise to the curve using the alpha stable distribution. This noisy signal is then put through a rolling mean filter. I also smooth a separate instance of the noisy curve using the arithmetic mean. I want to compare the SNR of the curve signal and demonstrate how the filter has improved the noisy signal. How can I do this?

Importing the signals x100

cd 'C:blah\blah\'
z_numfiles = 100;
for k = 1:z_numfiles
    myfilename = sprintf('scope_%d.csv', k);
    nometal{k} = xlsread(myfilename, 'C4:C500');
end

This is two instances of the "raw" signal capture:

enter image description here

Adding the impulse noise to the "nometal" signal and increasing the size of the dataset from x100 to x1000:

pd1 = makedist('Stable','alpha',0.5,'beta',0,'gam',0.001,'delta',0);
temp = 0;
distr_puls_nometal = cell(1000, 1);
samplesize = 497;
loop_count = 1000;
for n = 1:9
    for j = 1:loop_count
        temp = cell2mat(nometal(n));
        
        for i = 1:samplesize
            a = random(pd1);
            temp(i) = temp(i) + a;
            if temp(i) > 3
                temp(i) = 3;
            elseif temp(i) < 0
                temp(i) = 0;
            end
        end
        distr_puls_nometal{n+j} = temp;
    end
end

enter image description here

Comparing a rolling mean and an arithmetic mean of the noisy "no metal" signal:

enter image description here

How can I calculate the SNR decrease for the "noisy" signal? How can I caculate the signal improvement by attenuating the noise? I also have a number of other noise distributions but I assume that the process will be the same. Thanks all!

0

There are 0 answers