MATLAB: How to re-insert elements into a vector

arraydeleteelementinsertvector

I have outliers at the X-axis position 5785 and 7934.
outliers = 5785; 7934
In order to replace the outlying value, outliers are above mentioned points are deleted and a new 'corrected' values are created.
W(outliers) = []
x = 1:17280 % indices for x asix
x(outliers) = [] % deleting / emptying the value at the outlier position on x-axis
W_int = interp1(x',W, outliers)
How may i inserted the corrected value back in to the previously deleted position?

Best Answer

How about simply
W = filloutliers(W, 'linear');
If you want to supply the outliers yourself:
outliers = [5785; 7934];
x = 1:numel(W);
W = filloutliers(W, 'linear', 'OutlierLocations', any(x==outliers)');