Effacer les filtres
Effacer les filtres

area between a curve and a linear function

1 vue (au cours des 30 derniers jours)
moinmoinnoob69
moinmoinnoob69 le 1 Fév 2024
Commenté : Voss le 1 Fév 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!

Réponses (1)

Voss
Voss le 1 Fév 2024
y_downwards_limit = linspace(gerade_punkt2(1),gerade_punkt2(2),numel(Temparea)).';
area_between_curves = trapz(Temparea, DSCarea-y_downwards_limit)
  1 commentaire
Voss
Voss le 1 Fév 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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by