You can define the excluded points as variables before supplying them as inputs to the fit function. The following steps recreate the fits in the previous example and allow you to plot the excluded points as well as the data and the fit.

Load data and define a custom equation and some start points.

[x, y] = titanium;
gaussEqn = 'a*exp(-((x-b)/c)^2)+d'
startPoints = [1.5 900 10 0.6]

gaussEqn =
a*exp(-((x-b)/c)^2)+d
startPoints =
1.5000 900.0000 10.0000 0.6000

Define two sets of points to exclude, using an index vector and an expression.

exclude1 = [1 10 25];
exclude2 = x < 800;

Create two fits using the custom equation, startpoints, and the two different excluded points.

f1 = fit(x',y',gaussEqn,'Start', startPoints, 'Exclude', exclude1);
f2 = fit(x',y',gaussEqn,'Start', startPoints, 'Exclude', exclude2);

Plot both fits and highlight the excluded data.

plot(f1,x,y,exclude1)
title('Fit with data points 1, 10, and 25 excluded')
figure;
plot(f2,x,y,exclude2)
title('Fit with data points excluded such that x < 800')

For a surface fitting example with excluded points, load some surface data and create and plot fits specifying excluded data.

load franke
f1 = fit([x y],z,'poly23', 'Exclude', [1 10 25]);
f2 = fit([x y],z,'poly23', 'Exclude', z > 1);
figure
plot(f1, [x y], z, 'Exclude', [1 10 25]);
title('Fit with data points 1, 10, and 25 excluded')
figure
plot(f2, [x y], z, 'Exclude', z > 1);
title('Fit with data points excluded such that z > 1')