How to find data points within 2% tolerance of curve
2 views (last 30 days)
Show older comments
Suppose, I have any curve , assume y=x^2 . And I have some scatter data points(X,Y) . Then , how to find scattter data points which are in 2% tolerance of curve y=x^2.
0 Comments
Accepted Answer
Chad Greene
on 30 Apr 2021
Sounds like a nice homework problem.
You'll probably want to use logical indexing to find the indices of the Y data that are within some range of your predicted y curve.
If you wanted to find the indices of all Y values that are greater than 3 and less than 5, you'd do
ind = y>3 & y<5;
which would return true for all of the y values that are within that range.
Now try the same logic, but find the indices of all Y points that are greater than 0.98 of your x^2 curve, and less than 1.02.
1 Comment
Chad Greene
on 30 Apr 2021
Here's an example.
X = 1:100;
Y = 10*rand(100,1);
plot(X,Y,'.','color',0.8*[1 1 1])
Now the indices of all the Y data between 3 and 5:
ind = Y>3 & Y<5;
hold on
plot(X(ind),Y(ind),'ro')
More Answers (0)
See Also
Categories
Find more on Descriptive Statistics 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!