normalise two plot by there area
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Torsten
2023-12-20
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 ?
回答(1 个)
Sulaymon Eshkabilov
2023-12-20
Briefly speaking normalizartion means to have the values of a variable with respect to "some value" , e.g.:
A = [5 2 3 10]
% To normalize A w.r.t max value of A
A_normal = A/max(A)
figure(1)
plot(A, 'DisplayName','Original')
legend("Show")
figure(2)
plot(A_normal, 'DisplayName','Normalized')
legend("Show")
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!