Filter data directly in scatter graph

I am new to MATLAB, I want to filter some data on the image I send attached, I tried to use smooth funciton but I think it only works with plot and I want to be able to use it with the scatter function. I know I can erase this dots manually with the brush/select data directly in the graph, the thing is I have tens of this graphs. I want to be able to filter them in the graph not in the workspace. Is it even possible to do this? thanks.

4 Comments

Your image doesn't appear.
Looks like the question was edited but the image still doesn't appear. I wonder if you're experiencing a glitch in the updated format of the website.
Indeed I edited , I thought it has uploaded this time, I will upload it in here. cell11625C_25temp.jpg
There's lots of approaches to this problem.
1) Smoothing. Smoothing will definitely clean up the data but you'll have a bump around x=~900 where those cluster of data points are and you'll lose some of the features of the data like the sudden steps around x=~2800 and x=~3500.
2) Fitting. If you know what the shape of the line "should" be, you can fit the data to a function. In that case you'll end up with a very smooth line but you'll lose all of the variation.
3) Removing outliers. Matlab has several algorithms for detecting outliers in your data. You could detect the outliers and then remove them. That will preserve the main features of your data. For example, if you're using matlab 2017a or later, see
doc isoutlier()
.
Depending on your approach, there's lots of functions, tools, etc that matlab offers. But first you should decide on an approach which depends on how the data will be used, interpreted, etc.

Sign in to comment.

Answers (1)

KSSV
KSSV on 14 Nov 2018
Edited: KSSV on 14 Nov 2018
Let (x,y) be your data.
stdDev = std(y) ; % Compute standard deviation
meanValue = mean(y) ; % Compute mean
zFactor = 1.5; % or whatever you want.
% indices where outliers are present
idx = abs(y-meanValue) > (zFactor * stdDev);
% remove outliers
x(idx) = [] ;
y(idx) = [] ;
plot(x,y,'.')

1 Comment

This method doesn't work with the data Sebastian provided in the plot. This method would incorrectly get rid of data in the lower and upper ranges which is not what he's trying to do.

Sign in to comment.

Categories

Products

Release

R2018a

Asked:

on 13 Nov 2018

Commented:

on 14 Nov 2018

Community Treasure Hunt

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

Start Hunting!