% Run this several times to get many realizations on the same plot.
N=100;
t=linspace(0,1,N+2)';
t=t(2:end-1); % take off the (known) endpoints

tm=repmat(t,[1,N]);
C=min(tm,tm')-tm.*tm'; % cov=min(ti,tj)-ti*tj

%rng('default');
rng('shuffle');
X=randn(N,1); % X=N(0,1)

L=chol(C); % C=L*L'

B=L'*X; % Construct Brownian Bridge from X and L


plot([0;t;1],[0;B;0],'-o') % including endpoints
hold on