Hello,
If I have a set of data such as
X = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.85];
rA = [-.0053, -.0052, -.0050, -.0045, -.0040, -.0033, -.0025, -.0018, -.00125, -.0010];
plot(X,-1./rA)
and I want to know the area under the curve generated in the graph, how would I do that? There is no function involved here, this is just raw data, so I know I can't use quad or any of those integral functions.
Thanks

댓글 수: 3

Ashok
Ashok 2016년 7월 9일
% Find the number of pixels of the connected component
Bin_image - logical binary image CC = bwconncomp(Bin_image); CC numPixels = cellfun(@numel,CC.PixelIdxList); disp(numPixels);
% Find the number of pixels of the connected component
[Label,~]=bwlabel((Bin_image),8); [Label,~]=bwlabel(Bin_log_4mult,8); num=1; [row, ~] = find(Label==num); Obj_area=numel(row); display(Obj_area);
Samarth Patil
Samarth Patil 2018년 6월 7일
how to find the area in an interval for such a plot?
Krishnendu Mukherjee
Krishnendu Mukherjee 2018년 9월 12일
Thanks a lot. It helped a lot.

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

 채택된 답변

Star Strider
Star Strider 2014년 9월 9일
편집: Star Strider 2014년 9월 9일

20 개 추천

Use trapz. It’s designed to do exactly what you want.
Int = trapz(X, -1./rA)
produces:
Int =
306.7455

댓글 수: 5

Rick
Rick 2014년 9월 9일
편집: Rick 2014년 9월 9일
now how do I know if I should do trapz(X,-1./rA) or trapz(-1./rA,X)?? Which would give the area under the curve for the plot(X,-1./rA)??
The documentation is quite unclear to me, it says
Z = trapz(X,Y) computes the integral of Y with respect to X using
the trapezoidal method. X and Y must be vectors of the same
length, or X must be a column vector and Y an array whose first
non-singleton dimension is length(X). trapz operates along this
dimension.
if X is my x-axis and -1./rA is my y-axis, does that mean I should do trapz(X,-1./rA)??
‘if X is my x-axis and -1./rA is my y-axis, does that mean I should do trapz(X,-1./rA)??’
Yes. Actually, X is your independent variable and (-1./rA) is your dependent variable.
Use:
Int = trapz(X, -1./rA)
to produce:
Int =
306.7455
Krishnendu Mukherjee
Krishnendu Mukherjee 2018년 9월 12일
Thanks a lot :)
Saurabh Parmar
Saurabh Parmar 2020년 5월 25일
Thank You So Much! That helped a lot.
Star Strider
Star Strider 2021년 1월 16일
Everyone — My pleasure!

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

추가 답변 (1개)

Ashok
Ashok 2016년 7월 9일

0 개 추천

% Find the number of pixels of the connected component
Bin_image - logical binary image CC = bwconncomp(Bin_image); CC numPixels = cellfun(@numel,CC.PixelIdxList); disp(numPixels);
% Find the number of pixels of the connected component
[Label,~]=bwlabel((Bin_image),8); [Label,~]=bwlabel(Bin_log_4mult,8); num=1; [row, ~] = find(Label==num); Obj_area=numel(row); display(Obj_area);

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

질문:

2014년 9월 9일

댓글:

2021년 1월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by