area between a curve and a linear function
1 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(1 个)
Voss
2024-2-1
y_downwards_limit = linspace(gerade_punkt2(1),gerade_punkt2(2),numel(Temparea)).';
area_between_curves = trapz(Temparea, DSCarea-y_downwards_limit)
1 个评论
Voss
2024-2-1
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)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!