How to normalize a discrete signal?

Hello!!
I want to calculate the signal energy in rolling windows, after first normalizing to interval [-1,1].
Firstly, I wrote the below code to read and sound the signal.
[y,Fs] = audioread('viola_series.wav');
plot(y);
title('Audio viola series.wav');
sound(y,Fs);
How to do the normalization?
Thanks in advance

 Accepted Answer

Audio data are typically already normalized between [-1,1]. Are you getting values outside of that range?
min(y)
max(y)
Anyway, this is how to normalize any vector to [-1,1];
ynorm = (y-min(y))/range(y)*2-1;

5 Comments

RoBoTBoY
RoBoTBoY on 24 Jan 2021
Edited: RoBoTBoY on 24 Jan 2021
So that is the initial signal
And that is the normalized signal
How could I convert the x axis from 0 to 10 sec for both signals?
Adam Danz
Adam Danz on 24 Jan 2021
Edited: Adam Danz on 24 Jan 2021
Data from the first plot could also be normalized but without values larger than +/- ~0.025.
Data from the second plot are also normalized and consume the full normalized range.
> How could I convert the x axis from 0 to 10 sec for both signals?
You can use the same approach in my answer except multiply by 10 instead of 2 and no need to subtract 1.
I could not do it. But it does not matter.
Now I want to find the energy of this signal in rolling windows.
Note that the energy of a signal x[n] overlapping by a window w[n] is given by the following formula:
where as signal w[n] I will use the Hamming window given by the equation:
I will use window length N = 1000 samples.
I run the below code but without result.
syms m
w = hamming(1001);
energy_signal = symsum(conv(y_norm.^2,w),m,0,10);
plot(energy_signal);
How to do that?
The normalization to [0,10] would have been
n = (x-min(x))/range(x)*10;
Since you're new question differs greatly from the original one, it would be better to post it as a new question.

Sign in to comment.

More Answers (0)

Asked:

on 23 Jan 2021

Commented:

on 24 Jan 2021

Community Treasure Hunt

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

Start Hunting!