Designing a Filter in MATLAB

I have a matrix containing the x,y,z data of points. I want to implement a filter which removes a particular value which is due to some mathematical error
Pnts =
41.5 91.5 71.5
41.6 91.6 71.6
41.7 91.7 71.7
41.8 91.8 71.8
41.9 91.9 71.9
41.10 91.10 71.10
41.11 91.11 71.11
55.5 110.5 95.5
41.13 91.13 71.13
41.14 91.14 71.14
41.15 91.15 71.15
41.16 91.16 71.16
41.17 91.17 71.17
So the value which is 55.5 110.5 and 95.5 is a error value and has to be removed. So please someone help me how to proceed with this problem.
Thanks

4 Comments

Everyone is asking for MATLAB code, so please be more specific in your tags; see http://www.mathworks.co.uk/matlabcentral/answers/43073-a-guide-to-tags
When you say "filter", do you mean like an IIR or FIR filter, or a lowpass filter? Or like a convolution? Or just a bit of code that throws away those entries producing a smaller array?
Hello ,
Mr. Roberson I am sorry for using wrong tags for my question. In future I will remember your advice. Thanks
You can use "Add/Edit Tags" to change the tags here.

Answers (1)

You need to figure out a rule yourself because other people cannot know why the specific row is an error but others are not. Using your example, assume the rule is "anything greater than 42 is an error", then you can remove the line by doing
Pnts(Pnts(:,1)>42,:) = []

5 Comments

Hello ,
The problem is the data set is varying and in the complete data set maybe one or two values are far away from the actual data set . These values have to be removed from the data set.
So what you want is "outlier detection".
@Jatin, that's exactly what I mean. You need to define your outlier criteria first before other people can chime in and help. One possible criteria is four times standard deviation. HTH.
@Walter Yes I am looking for outlier detection for n*3 Matrix. @Honglei For defining the criteria I want to use a user input which can be specified in a variable.I will try to work more on the problem.
Thanks for your comments
Outlier detection in multiple dimensions can get a bit tricky. You could do the detection in terms of Euclidean distance (or other distance) from the centroid of all of the points together, but that can easily miss outliers that humans would pick out quickly. In particular if there are multiple clusters, it can be better to cluster the image first and then determine outliers relative to the deemed cluster.
In some cases it makes the most sense to use PCA to find the principle axes through the cloud, and then rotate the coordinates to align with those axes, and then to use something like the multi-dimensional equivalent of an ellipse aligned along the new X-Y-Z axes, with the exclusion criteria being determined according to distance from the outer shell of the ellipsoid (e.g., when one is working with points that are roughly on a surface surrounding a centroid, as opposed to working with points that are inside a surface surrounding a centroid.
If all you can say is that the points are in 3-space then the outlier detection will probably end up being pretty crude.

This question is closed.

Tags

Asked:

on 12 Nov 2012

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!