Removing Unwanted data from a bunch of data
3 ビュー (過去 30 日間)
古いコメントを表示
Hey there everyone
I have a set of data of an eye digram (which I attached its .mat file) and clustered it by color as shown below. However, there are a disturbing line crossing the eye diagram and made it untidy and I intend to remove it (as I indicated in the second shape with black highlighter) but I do not know how to do it. I attached the code by the way to get the main output but removing those unwanted data and make the diagram looks clean is my problem
Can anyone help me do this?
0 件のコメント
回答 (1 件)
Image Analyst
2020 年 7 月 11 日
One way to do it is to fit a quadratic to 3 points, the points closest to x=-0.2, x=0.3, and x=0.6
coefficients = polyfit([x1,x2,x3], [y1,y2,y3], 2); % FIt quadratic.
If the coefficient of the squared term is small enough, then it's a straight line between the left and right point and that means it's the segment you want to ignore.
if coefficients(1) < someValue
% Don't include this segment
end
First go through and print out what all the coefficients are to see what most values are. Take the histogram of all the coefficients to see what are normal values and what are bad values that you want to exclude.
3 件のコメント
Image Analyst
2020 年 7 月 11 日
At some point in your code do you have all the x and y into distinct rows or columns of a 2D matrix? I mean can we at some point do this (assuming each row of x or y is a single plot line):
[rows, columns] = size(x);
keeperRows = true(rows, 1);
allCoeffs = true(rows, 1);
for row = 1 : rows
thisX = x(row, :);
thisY = y(row, :);
index1 = 1;
index2 = find(x > 0.2, 1, 'first');
index3 = find(x > 0.8, 1, 'first');
coefficients = polyfit([x(index1),x(index2),x(index3)], [y(index1),y(index2),y(index3)], 2); % FIt quadratic.
allCoeffs(row) = coefficients(1);
if coefficients(1) < 0.1 % or whatever.... I have no idea
keepers(row) = false;
end
end
% Extract only the keepers
x = x(keepers, :);
y = y(keepers, :);
% Let's see what the coefficients of the squared terms are.
histogram(allCoeffs); % Let's visualize what all the slopes were so we can see what value an outlier would have.
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!