How to get the mean value from one point to another in a plot

Hello,
I want to calculate the mean value from 0.4 to 0.5 of this graph. Is it possible to get the mean value

 Accepted Answer

Yes. Just use masking to get the indexes, then use mean() to get the mean in that range.
indexes = x >= 0.4 & x <= 0.5;
meanValue = mean(y(indexes))
or if you just want from 0.4 to the end:
indexes = x >= 0.4;
meanValue = mean(y(indexes))

1 Comment

It really doesn't get more detailed than that, unless you want to do fancy stuff like indicate the mean somehow on your plot, or print out the value, or export it to Excel, or popup a message to the user, etc.
Make it easy for me to help you. Attach your data along with code to read it in.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!