# given that you have this line of code how do you count the number of points in each quadrant ?

34 views (last 30 days)
Afua Amoako Dadey on 12 Jul 2020
Edited: Adam Danz on 15 Jul 2020 at 13:55
Classical = pdist2(matrix_logdiff_nsample, mean(matrix_logdiff_nsample),'mahal');
p = size(matrix_logdiff_nsample,2);
chi2quantile = chi2inv(0.99,p);
[SFmcd, MFmcd, Fmcd, OutFmcd] = robustcov(matrix_logdiff_nsample);
plot(Classical, Fmcd, 'o')
line([chi2quantile, chi2quantile], [0, 120], 'color', 'r')
line([0, 80], [chi2quantile, chi2quantile], 'color', 'r')
hold on
plot(Classical(OutFmcd), Fmcd(OutFmcd), 'b*')
xlabel('Mahalanobis Distance')
ylabel('Robust Distance')
title('Distance Plot, Fast MCD method')

jonas on 12 Jul 2020 at 18:53
Adam Danz on 12 Jul 2020 at 21:31

Adam Danz on 12 Jul 2020 at 21:34
Edited: Adam Danz on 13 Jul 2020 at 11:10
You just need to modify either of the two answers received for similar questions in the past (listed under your question).
To modify this answer, you just need to replace the centerPoint_x, centerPoint_y values with the coordinates you're using to define the quadrants.
Based on your image it would look something like,
centerPoint_x = 15; % approximate guess based on image
centerPoint_y = 18; % approximate guess based on image

Afua Amoako Dadey on 13 Jul 2020 at 15:50
ok let me share
Classical = pdist2(matrix_logdiff_nsample, mean(matrix_logdiff_nsample),'mahal');
p = size(matrix_logdiff_nsample,2);
chi2quantile = chi2inv(0.99,p);
[SFmcd, MFmcd, Fmcd, OutFmcd] = robustcov(matrix_logdiff_nsample);
plot(Classical, Fmcd, 'o')
line([chi2quantile, chi2quantile], [0, 120], 'color', 'r')
line([0, 80], [chi2quantile, chi2quantile], 'color', 'r')
hold on
plot(Classical(OutFmcd), Fmcd(OutFmcd), 'b*')
xlabel('Mahalanobis Distance')
ylabel('Robust Distance')
title('Distance Plot, Fast MCD method')
centerPoint_y = 18;
centerPoint_x = 15;
centerPoint_x = min(xlim) + range(xlim)/2;
centerPoint_y = min(ylim) + range(ylim)/2; % Same thing as above but with ylim
quad1 = x >= centerPoint_x & y >= centerPoint_y;
quad2 = x < centerPOint_x & y >= centerPoint_y;
% %quad3 = % fill in....
% %quad4 = % file in....
% % Points that are in Quad1 are
counts = accumarray([1+(matrix_logdiff_nsample(:)>=mean(matrix_logdiff_nsample)), 1+(matrix_logdiff_nsample(:)>=mean(matrix_logdiff_nsample))], 1, [2 2]);
Afua Amoako Dadey on 13 Jul 2020 at 15:56
This is the error message
Adam Danz on 13 Jul 2020 at 16:07
You need to exchange "x" and "Y" with whatever values you're using to define the center point. Don't just copy-paste without doing the thinking. 