How to extract the scatter data based on a function

조회 수: 2 (최근 30일)
joynjo
joynjo 2018년 7월 18일
편집: joynjo 2018년 7월 21일
I have a scatter data as attached image follows, how to sign the data outside the function line with '1' and the data under the function line with '0' then save it into one variable?
  댓글 수: 1
joynjo
joynjo 2018년 7월 21일
Up, I am still waiting for anyone who can help me solve this problem, thanks

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

답변 (1개)

Image Analyst
Image Analyst 2018년 7월 18일
I have no idea what "sign the data" with 0 or 1 means, but to get the data under and above/outside the function, try something like this
indexesUnderTheCurve = false(1, length(x));
for k = 1 : length(x)
thisX = x(k);
thisY = y(k);
curveY = YourFunction(thisX); % Plug the x into your custom function
if thisY < curveY
% Under the curve
indexesUnderTheCurve(k) = true;
end
end
xUnder = x(indexesUnderTheCurve);
yUnder = y(indexesUnderTheCurve);
xOver = x(~indexesUnderTheCurve);
yOver = y(~indexesUnderTheCurve);
  댓글 수: 5
Image Analyst
Image Analyst 2018년 7월 21일
To help me from transferring all that code, can you attach your m-file?
joynjo
joynjo 2018년 7월 21일
편집: joynjo 2018년 7월 21일
please kindly find m file for my QDA classification as attached included with the related files.

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

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by