%% Specify Custom Transition Function
% Create smooth threshold transitions with the following qualities:
% Mid-levels are at -1, 1, and 2.
% The transition function is the Student's t cdf, which allows for a more gradual mixing than the normal cdf.
% The transition rates, which are the degrees of freedom of the distribution, are 3, 10, and 100.

t = [-1 1 2];
r = [3 10 100];
ttransfcn = @(z,ti,ri)tcdf(z,ri);
tt = threshold(t,Type="custom",TransitionFunction=ttransfcn,Rates=r)

% Plot graphs of each transition function.

figure
ttplot(tt,Type="graph")
legend(string(tt.Levels))

% Copyright 2021 The MathWorks, Inc.