필터 지우기
필터 지우기

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 CenterFile Exchange에서 Numerical 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