MATLAB: Finding how many percent of data point lies below the curve.
plotting
Hi everyone,
I plotted many data points on one plot. I am trying to find out how to get the percentage or the number of how many data points lie below a certain curve that drew. Is there a way to do this in matlab?
Thank you
Best Answer
It quite likely is, but it depends on what you are doing. You didn’t go into any specifics, but if you have the curve defined at the same values of your independent variable as the data (for example, a regression curve), simply comparing the curve and the data at those points would be sufficient.
If the curve is relatively free-form, and not defined (or cannot be defined) at the same values as your independent variable, theinpolygon function would probably do what you want.
You could save your fitting values to workspace, using cftool choose analysis and there select the option evaluate fit at Xi (in your case Xi is your x) . Now if you save those results you 'll have a structure containing xi and yfit. You can calculate percent residuals r(%)=100*(yi-yifit)./yi. Just be careful in case your original data aren't sorted by x value to sort them because the output results of fitting analysis are sorted to xi.
Best Answer