2
$\begingroup$

I'm quite new to Mathematica. I need to calculate the area below many curves imported from excel.

I wrote this code:

curve={{{0,0},{0.1,1},{0.2,10},{0.22,20},{0.3,50},{0.4,20}},{{0,0},{0.15,5},{0.25,10},{0.27,20},{0.3,40},{0.5,30}}};

(plot) dataPlot =Table [ListLinePlot[l, PlotRange -> All], {l, curve}]

(find the interpolating curves) f = Table[Interpolation[l, InterpolationOrder -> 1], {l, curve}];

I've originally written the code for one curve, and I don't know how to write this last part of the code for n curves:

Plot[f[t], {t, 0, Max@x}]

NIntegrate[f[t], {t, 0, Max@x}]

I would also need to calculate the areas between 0 and the x values which correspond to the maximum y values

Thank you in advance!

$\endgroup$
2
  • $\begingroup$ Welcome to the Mathematica Stack Exchange. What is your estimation of the area for curve[[1]] and curve[[2]] ? Specifically, why are you trying to interpolate first and then use NIntegrate instead of just summing up? $\endgroup$
    – Syed
    Mar 13, 2022 at 9:37
  • $\begingroup$ Similar to 183935. $\endgroup$
    – Syed
    Mar 13, 2022 at 10:14

1 Answer 1

3
$\begingroup$
curve = {{{0, 0}, {0.1, 1}, {0.2, 10}, {0.22, 20}, {0.3, 50}, {0.4, 
     20}}, {{0, 0}, {0.15, 5}, {0.25, 10}, {0.27, 20}, {0.3, 
     40}, {0.5, 30}}};
plots = Table[
  ListLinePlot[l, PlotRange -> All, Filling -> Axis], {l, curve}]
DiscretizeGraphics /@ plots // Area

enter image description here

{7.2, 9.325}

$\endgroup$
1
  • $\begingroup$ Hi! Thanks for your time. Your method is good, but unfortunately, it takes too much time when you have to work with experimental curves that involve hundreds of points. $\endgroup$
    – Carolyn
    Apr 14, 2022 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.