MATLAB Answers

How to find data points within 2% tolerance of curve

조회 수: 5(최근 30일)
Aiden James
Aiden James 2021년 4월 30일
댓글: Chad Greene 2021년 4월 30일
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.

채택된 답변

Chad Greene
Chad Greene 2021년 4월 30일
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
Chad Greene
Chad Greene 2021년 4월 30일
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

댓글을 달려면 로그인하십시오.

추가 답변(0개)


Community Treasure Hunt

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

Start Hunting!

Translated by