close all; clear; clc;

%%
N = 2^4;
TM = mod(sum(arrayfun(@(x)arrayfun(@(x)x=='1',x),dec2bin(0:(N-1))),2),2);

% Plot
figure(1); clf; hold on;
plot(1:N,TM,'-o');
grid on; box on; axis equal tight;
xlim([0 N+1]); ylim([-.5 1.5]);
a = gca; a.YTick = [0 1]; a.XTick = 2.^(0:log2(N));
title('Thue-Morse sequence');