%% Bernstein2
%% 1

f = @(x)rectangularPulse(1/4,3/4,x);
b1 = bernstein(f, 100, sym('t'));
b2 = simplify(b1);
f1 = matlabFunction(b1);
f2 = matlabFunction(b2);

%
%% 2

t = 0:0.001:1;
plot(t, f(t), t, f1(t), t, f2(t))
hold on
legend('original function','Bernstein polynomial',...
                'simplified Bernstein polynomial')
hold off

% Copyright 2015 The MathWorks, Inc.