norm in matlab

Normalization in MATLAB can be achieved by dividing a signal by its maximum value or its sum. Here's an example of normalizing a signal (represented by a vector x) using its maximum value:

main.m
%Generating a signal
x = rand(1, 100); %vector with 100 random values between 0 and 1

%Normalizing the signal
x_norm = x / max(abs(x)); %dividing each value by the maximum value of the signal
193 chars
6 lines

In this example, we divide each value of the signal by the maximum absolute value of the signal (using the abs function to remove any negative values). This will result in a normalized signal whose maximum value equals 1. You can also divide by the sum of the signal to obtain a signal with unit energy.

related categories

gistlibby LogSnag