cnn_setenv;
mCNN.TemGroup = 'temlib_diff';

length = 40;

init_state = zeros(40,3);
init_state(:,2) = [1 1 1 1 1 linspace(-1,-1,35)];

input = zeros(size(init_state));
mCNN.INPUT1 = input;
mCNN.STATE = 1.*init_state; %init_state;
mCNN.Boundary = 3; % [-1 ... 1] --> const, 2 --> zeroflux, 3 --> periodic
mCNN.TimeStep = 0.1;
mCNN.IterNum = 5;
loadtem('WAVE');

% and plot the results:
figure;
subplot(1, 3, 1);
plot(input(:,2));
title('input', 'FontSize', 12, 'FontWeight', 'bold');
ylim([-1 1])
subplot(1, 3, 2);
plot(init_state(:,2)); %init_state);
ylim([-1 1])
title('initial state', 'FontSize', 12, 'FontWeight', 'bold');
subplot(1, 3, 3);
for ind = 1:100
    runtem; % run the simulator
    plot(mCNN.OUTPUT(:,2));
    ylim([-1.2 1.2]);
    drawnow
    title(['output i=', num2str(ind)], 'FontSize', 12, 'FontWeight', 'bold');
end

