フィルターのクリア

area between a curve and a linear function

1 回表示 (過去 30 日間)
moinmoinnoob69
moinmoinnoob69 2024 年 2 月 1 日
コメント済み: Voss 2024 年 2 月 1 日
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!

回答 (1 件)

Voss
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
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)
area_between_curves = 11.1183

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by