How to normalize a matrix such that the maximum value is 1?

조회 수: 20 (최근 30일)
hithere
hithere 2014년 12월 31일
댓글: Thamires Lima 2017년 10월 5일
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?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 12월 31일
If you have Image Processing Toolbox
new_y1=mat2gray(y1);
new_y2=mat2gray(y2);
% new_y1 and new_y2 have both the same minimum equal to 0 and maximum equal to 1
  댓글 수: 5
Azzi Abdelmalek
Azzi Abdelmalek 2015년 1월 1일
out=cell2mat(arrayfun(@(x) mat2gray(A(x,:)),(1:size(A,1))','un',0))
Thamires Lima
Thamires Lima 2017년 10월 5일
And, If, do I have an errorbar (y2) associated to y1 how should I write this new errrorbar (new_y2), after normalizing y1 to new_y1?

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Matt J
Matt J 2014년 12월 31일
편집: Matt J 2014년 12월 31일
signal = signal/norm(signal,inf) ;

Image Analyst
Image Analyst 2014년 12월 31일
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]);

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by