How to normalize a matrix such that the maximum value is 1?
Show older comments
I have 2 matrices. I plot them against a common x-axis

.
Now I like to normalize both signal such that the largest peak of each signal is 1 so that I can compare the signals.
How should I go about doing it?
Accepted Answer
More Answers (2)
signal = signal/norm(signal,inf) ;
Image Analyst
on 31 Dec 2014
What about the min? Do you want that to be mapped to 0, or whatever it ends up being? If it's whatever, then (untested):
y1Normalized = y1 / max(y1);
p1 = subplot(1, 2, 1);
plot(x1, y1Normalized );
% Find what it picked as the nice ranges for the y axis:
yAxis1 = ylim();
y2Normalized = y2 / max(y2);
p2 = subplot(1, 2, 2);
plot(x2, y2Normalized);
% Find what it picked as the nice ranges for the y axis:
yAxis2 = ylim();
% Figure out what the y axis range needs to be to accomodate both plots.
yMin = min([yAxis1, yAxis2]);
yMax = max([yAxis1, yAxis2]);
% Set a common y axis range for both of them.
ylim(p1, [yMin, yMax]);
ylim(p2, [yMin, yMax]);
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!