normalise two plot by there area

6 visualizzazioni (ultimi 30 giorni)
Sung YunSing
Sung YunSing il 20 Dic 2023
Modificato: Sung YunSing il 21 Dic 2023
Hi everyone
I will get severals datas( e.g. nx100 double ) and going to plot on figure.
However, I need to normalise each data lines by their area.
Then plot the new datas on the figure.
I just know I can have the area of the plot by instruction: boundary.
But I have no idea to do the normalization parts.
Do you have any suggestions?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21/12 edit
sorry
may i clarify my question
for example
x=1:1:100;
y(1,:)=x;
y(2,:)=x/2;
y(3,:)=x/4;
%y consider as my three data
figure
for i=1:3
plot(x,y(i,:))
area(i)=trapz(y(i,:));
hold on
end
%here we can get a figure of data plots and their area (with x axis)
%we can notice the areas of three data are different
L=area(1)*area(2)*area(3);
%here is just a simple lcm.
figure
for j=1:3
Y(j,:)=y(j,:)*L/area(j);
plot(x,Y(j,:))
hold on
end
% Y would be the data i really want because the areas of the three data are
% same.
However, the lcm part (or normalise part) is quite inefficient when my data are too complex or large.
wondering is there another way to revise it.
  1 Commento
Torsten
Torsten il 20 Dic 2023
I will get severals datas( e.g. nx100 double ) and going to plot on figure.
So you have n data lines ?
However, I need to normalise each data lines by their area.
The area between the data line and the x-axis ? What are the x-axis values corresponding to the 100 data of each of the n data lines ?

Accedi per commentare.

Risposte (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov il 20 Dic 2023
Briefly speaking normalizartion means to have the values of a variable with respect to "some value" , e.g.:
A = [5 2 3 10]
A = 1×4
5 2 3 10
% To normalize A w.r.t max value of A
A_normal = A/max(A)
A_normal = 1×4
0.5000 0.2000 0.3000 1.0000
figure(1)
plot(A, 'DisplayName','Original')
legend("Show")
figure(2)
plot(A_normal, 'DisplayName','Normalized')
legend("Show")

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by