Filter löschen
Filter löschen

area between a curve and a linear function

1 Ansicht (letzte 30 Tage)
moinmoinnoob69
moinmoinnoob69 am 1 Feb. 2024
Kommentiert: Voss am 1 Feb. 2024
Hi guys and girls,
I have x & y data for a curve. I want to calculate the area under the curve. So i generated a linear function as "downwards-limit".
I tried to use the trapz() function;
area_between_curves = trapz([Temparea,DSC],abs([gerade_punkt1,gerade_punkt2]-[Temparea,DSC]));
but i didn't manage to make it work...
A1 = readmatrix("Data_neu.txt");
Temp = A1(:,1); %[°C]
%Time = A1(:,2); %[min]
DSC = A1(:,3); %[mW/mg]
%Sensit = A1(:,4); %[uV/mW]
%Segment = A1(:,5);
gerade_punkt1 = [227.278,248.0764]; %[227.278,2.5461];
gerade_punkt2 = [2.5461,2.778]; %[244.423,2.7609];
%
Temparea = Temp(1017:1120,1);
DSCarea = DSC(1017:1120,1);
%plot
figure("Name","heat fusion")
hold on
plot(Temparea,DSCarea)
plot(gerade_punkt1,gerade_punkt2)
grid on
hold off
Thanks a lot!

Antworten (1)

Voss
Voss am 1 Feb. 2024
y_downwards_limit = linspace(gerade_punkt2(1),gerade_punkt2(2),numel(Temparea)).';
area_between_curves = trapz(Temparea, DSCarea-y_downwards_limit)
  1 Kommentar
Voss
Voss am 1 Feb. 2024
A1 = readmatrix("Data_neu.txt");
Temp = A1(:,1); %[°C]
DSC = A1(:,3); %[mW/mg]
start_idx = 1017;
end_idx = 1120;
Temparea = Temp(start_idx:end_idx,1);
DSCarea = DSC(start_idx:end_idx,1);
%plot
figure("Name","heat fusion")
hold on
plot(Temparea,DSCarea)
plot(Temparea([1,end]),DSCarea([1,end]))
grid on
hold off
y_downwards_limit = linspace(DSCarea(1),DSCarea(end),end_idx-start_idx+1).';
area_between_curves = trapz(Temparea, DSCarea-y_downwards_limit)
area_between_curves = 11.1183

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by