Calculating the area under a curve using cell arrays
Show older comments
Afternoon everyone,
I have spent nearly a week trying to fix this problem and I am completely stuck.
Attached is the data set, each row is a node and each column is a time step, what I need to is calculate the area under the curve when y=0 for each row. Within the data, the peaks and troughs are not in fixed positions because of the phase shift, this leads to problem with errors (logical arrays and 0's) when using intrepl and trapz. Another problem in the data is that for certain rows (390-410) around col. 800 there a small peak that gets referenced as a peak and zero crossing point, as its value is soo close to zero.
Fig 1 (area of dPWP) shows is an area plot under each undulation, I need is the area above and below y=0. Fig 2 (area under trapz) is the area that my code is calculating, which is calcuating only the peaks and fig 3 (based vs peaks) shows the relation between the two.
If you would like to see the entire code let me know, but it is long because I have been addressing the errors above and it may require a bit of explaining but is based on Star Striders (https://uk.mathworks.com/matlabcentral/answers/314470-how-can-i-calculate-the-area-under-a-graph-shaded-area)
2 Comments
Star Strider
on 4 Dec 2019
The ‘PWP_diff’ variable is a (449 x 1199) matrix.
What do we do with it?
Richard Rees
on 4 Dec 2019
Accepted Answer
More Answers (1)
Richard Rees
on 6 Dec 2019
1 vote
5 Comments
Star Strider
on 6 Dec 2019
As always, my pleasure!
Richard Rees
on 31 Jan 2020
Star Strider
on 31 Jan 2020
Unless the new topic is closely-related (might simply require a minor tweak to this code), it would likely be better to ask a new Question.
Richard Rees
on 31 Jan 2020
Star Strider
on 31 Jan 2020
As always, my pleasure!
I’ll look for it ...
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

%20-%202019%2012%2004.png)