How to find area under curve

조회 수: 102 (최근 30일)
jjxc
jjxc 2021년 10월 8일
댓글: jjxc 2021년 10월 8일
I imported a set of data into matlab and have plotted the curve. However, I do not know how to use trapz to find the area under the curve.

채택된 답변

the cyclist
the cyclist 2021년 10월 8일
I did not open your text file, but assuming you got that plot using
plot(x,y)
then it should be as easy as
trapz(x,y)
  댓글 수: 3
the cyclist
the cyclist 2021년 10월 8일
% Load data
data = readtable('discharge 30mA.txt');
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
% Drop the last point, which is NaN
x = data{1:end-1,1};
y = data{1:end-1,2};
% Plot the data
figure
plot(x,y)
% Calculate the area
area = trapz(x,y)
area = 813.2263
jjxc
jjxc 2021년 10월 8일
oh okay i can understand the steps. Thank you for the help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by