%heat distribution 1D

clear all;
close all;

cnn_setenv;

mCNN.TemGroup='temlib_diff';
Length=20;

InitState=zeros(Length,3);
for a=1:Length
   InitState(a,:)=(2*exp(0.2*(-a+0.5)))-1;
end

State=1.*InitState;
for repeat=1:100
    mCNN.INPUT1=1*zeros(Length,3);
    mCNN.STATE=1*State;
    mCNN.Boundary=2;
    mCNN.TimeStep=0.01;
    mCNN.IterNum=1;

    loadtem('HEAT')
    runtem;
    
    State=1.*mCNN.STATE;

    subplot(1,2,1);
    plot(InitState(:,2));
    subplot(1,2,2);
    plot(mCNN.OUTPUT(:,2));
    axis([0 Length -1 1]);
    drawnow
end