why do i got negative infinite (- inf) in SNR?

2 views (last 30 days)
hi, i want to calculate snr value from 2 signal. one of them is speech.wav and the second one is speechcompressed. to make sure there is no delay,i use cross correlation for them. the snr result that i got is infinite, could u help me please?
[audio1,fs]=audioread('speech.wav');
[audio_compressed,fs]=audioread('speechcompressed.wav');
total_frame = round(length(audio1)/1024);
snr_frame_db = zeros(1,total_frame);
for k=1:total_frame-1
sample_start = k*1024-1023;
sample_end = k*1024;
signal_frame = audio_compressed(sample_start:sample_end);
error_frame = audio1(sample_start:sample_end)-signal_frame;
power_signal = sum(signal_frame.*signal_frame);
power_error = sum(error_frame.*error_frame);
snr_frame = power_signal/power_error;
snr_frame_db(k) = 10*log10(snr_frame);
end
mean(snr_frame_db)

Answers (0)

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!