How to extract the scatter data based on a function

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 个评论

Up, I am still waiting for anyone who can help me solve this problem, thanks

请先登录,再进行评论。

回答(1 个)

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 个评论

thanks for your reply I follow your code with the below function line: myfunction=@(x,y)k+l(1)*x+l(2)*y+q(1,1)*x.^2+(q(1,2)+q(2,1))*x.*y+q(2,2)*y.^2 but in this case, the function consist from x and y, hence when I only put 'myfunction(thisX), it will result an Error message 'Not enough input arguments'
Please attach a .mat file that you create with save() with your x and y and class information.
I follow this reference
Please kindly find the function and x y data as attached. Actually, it is Quadratic Discriminant Analysis for image. x is Discriminant-1 and y is Discriminant-2 image data. I need to recognize pattern on this image by classifying into 2 categories: 1st class is under curve and 2nd class is over curve then show them into a binary image.
Would you please help how to save undercurve and overcurve data?
To help me from transferring all that code, can you attach your m-file?
please kindly find m file for my QDA classification as attached included with the related files.

请先登录,再进行评论。

提问:

2018-7-18

编辑:

2018-7-21

Community Treasure Hunt

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

Start Hunting!

Translated by