How to find area under curve

114 ビュー (過去 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 Center および File ExchangeNumerical 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