Calculation of a given area using the trapz

조회 수: 5 (최근 30일)
Jacqueline Rigatto
Jacqueline Rigatto 2020년 12월 2일
댓글: Jon 2020년 12월 2일
Hello, to calculate the total area I used the trapz and it worked, but I can't do it for a certain area (figure above inside the red rectangle). If you can calculate, do I use trapz or do I use another? Show me how you do, please.
Thanks

채택된 답변

Jon
Jon 2020년 12월 2일
편집: Jon 2020년 12월 2일
You need to limit the range of x and y that are fed to trapz, you could do something like this, assuming your original variables are called x and y (modify accordingly for your actual variable names)
% assume x and y are defined earlier
% define range of interest
xRange = [21,31.3]
% find logical indices for range of interest
idl = x >= xRange(1) & x <= xRange(2);
% provide just values of interest to trapz
A = trapz(x(idl),y(idl))
  댓글 수: 2
Jacqueline Rigatto
Jacqueline Rigatto 2020년 12월 2일
Thanks for the help, Jon
Jon
Jon 2020년 12월 2일
Your welcome

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by