Remove outliers but be careful with end points
Hi, I have some typcial data like this that I want to remove the outliers (red arrows)
I use the rmoutliers function and then fillmissing to handle these.
%For last plotted Data
ax=app.UIAxes3;
[datax,datay] = getDataFromGraph(app,ax,1); % my fucntion that gets the last plot x and y values.
A=[datax datay];
[B,TFrm,TFoutlier] = rmoutliers(A,"movmedian",10);
x=B(:,1); y=B(:,2); hold(ax,"on");
The contraint I have is if I remove an outlier from the 1st or last data point (i.e. green arrow above), then it MUST be replaced with e.g the nearest non outlier.
So I thought this would do it:
F = fillmissing(y,’linear’,’EndValues’,’nearest’); %F = fillmissing(y,’movmedian’,10);
plot(ax,x,F,’.-‘);
However, its ignoring the last point (I dont mind other outliers being ignored, I just need the starting x and finishing x to be the same as the original data
ThanksHi, I have some typcial data like this that I want to remove the outliers (red arrows)
I use the rmoutliers function and then fillmissing to handle these.
%For last plotted Data
ax=app.UIAxes3;
[datax,datay] = getDataFromGraph(app,ax,1); % my fucntion that gets the last plot x and y values.
A=[datax datay];
[B,TFrm,TFoutlier] = rmoutliers(A,"movmedian",10);
x=B(:,1); y=B(:,2); hold(ax,"on");
The contraint I have is if I remove an outlier from the 1st or last data point (i.e. green arrow above), then it MUST be replaced with e.g the nearest non outlier.
So I thought this would do it:
F = fillmissing(y,’linear’,’EndValues’,’nearest’); %F = fillmissing(y,’movmedian’,10);
plot(ax,x,F,’.-‘);
However, its ignoring the last point (I dont mind other outliers being ignored, I just need the starting x and finishing x to be the same as the original data
Thanks Hi, I have some typcial data like this that I want to remove the outliers (red arrows)
I use the rmoutliers function and then fillmissing to handle these.
%For last plotted Data
ax=app.UIAxes3;
[datax,datay] = getDataFromGraph(app,ax,1); % my fucntion that gets the last plot x and y values.
A=[datax datay];
[B,TFrm,TFoutlier] = rmoutliers(A,"movmedian",10);
x=B(:,1); y=B(:,2); hold(ax,"on");
The contraint I have is if I remove an outlier from the 1st or last data point (i.e. green arrow above), then it MUST be replaced with e.g the nearest non outlier.
So I thought this would do it:
F = fillmissing(y,’linear’,’EndValues’,’nearest’); %F = fillmissing(y,’movmedian’,10);
plot(ax,x,F,’.-‘);
However, its ignoring the last point (I dont mind other outliers being ignored, I just need the starting x and finishing x to be the same as the original data
Thanks rmoutliers, fillmissing MATLAB Answers — New Questions