Signal normalization is common in signal processing, especially when a signal emerges from a filtering process. For example, you can normalize a highly attenuated filtered signal to an amplitude range of -1 to 1.
MATLAB Script
% Parameters for the sine wavefs = 1000; % Sampling frequency
t = 0:1/fs:1; % Time vector
f = 15; % Frequency of the sine wave
% Example signal: Noisy sine wave
filtered_signal = 0.03*sin(2 * pi * f * t) + 0.05*sin(2 * pi * f * t);
% Step 2: Normalize the filterd signal to the range [-1, +1]
normalized_signal = (filtered_signal - min(filtered_signal)) / (max(filtered_signal) - min(filtered_signal));
normalized_signal = normalized_signal * 2 - 1; % Scale to [-1, +1]
% Original Signal
figure();
plot(t, filtered_signal, 'b', 'LineWidth', 1.5);
title('Filtered Signal');
xlabel('Time (s)');
ylabel('Amplitude');
ylim([-0.1 0.1]);
grid on;
% Normalized Signal
figure();
plot(t, normalized_signal, 'g', 'LineWidth', 1.5);
title('Normalized Signal [-1, +1]');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
Output
Copy the MATLAB Code from here
Normalize a Highly distorted filtered signal
When normalizing a filtered signal, you may observe that the initial data points are often highly distorted, while the remainder of the signal appears stable. Therefore, it's recommended to discard the first N points (where N is the filter order) before performing normalization.
MATLAB Script
fs = 1000; % Sampling frequency
t = 0:1/fs:1; % Time vector
t1 = N/fs:1/fs:1;
f = 15; % Frequency of the sine wave
% Example signal: Noisy sine wave
filtered_signal = 0.03*sin(2 * pi * f * t) + 0.05*sin(2 * pi * f * t);
N = 10; % N = Filter order
signal1 = filtered_signal(1:N) * 15;
signal2 = filtered_signal(N+1:end);
filtered_signal = [signal1 signal2];
% Normalize the filterd signal to the range [-1, +1] without discarding
% first N-points (N = order of filter)
normalized_signal = (filtered_signal - min(filtered_signal)) / (max(filtered_signal) ...
- min(filtered_signal));
normalized_signal = normalized_signal * 2 - 1; % Scale to [-1, +1]
% Normalize the filterd signal to the range [-1, +1]
normalized_signal1 = (filtered_signal(N+1:end) - min(filtered_signal(N+1:end))) / (max(filtered_signal(N+1:end)) ...
- min(filtered_signal(N+1:end)));
normalized_signal1 = normalized_signal1 * 2 - 1; % Scale to [-1, +1]
% Original Signal
figure();
plot(t, filtered_signal, 'b', 'LineWidth', 1.5);
title('Highly Distorted Filtered Signal');
xlabel('Time (s)');
ylabel('Amplitude');
ylim([-1 1]);
grid on;
% Normalized Signal
figure();
plot(t, normalized_signal, 'g', 'LineWidth', 1.5);
title('Normalized Signal [-1, +1] without discarding first N-points');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
% Normalized Signal
figure();
plot(t1, normalized_signal1, 'g', 'LineWidth', 1.5);
title('Normalized Signal [-1, +1]');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;