Instructions for getting the MATLAB simulations to work properly

It was recently brought to my attention that the MATLAB scripts provided will not necessarily work right straight out of the box. So here are some instructions for using them:

  1. Run td_250.m: this will create the disturbance and a couple other signals via Simulink, and save them to th250.mat file.
  2. Run lms2.m: this trains the neural network according to the training data found within th250.mat . If you have problems with lms2, try adding the line epoch = 1; J(1) = 10000; after the line lEpoch = length(ThD), . You also might want to make some of the diplayed lines a little more meaningful:
    | From: lEpoch = length(ThD),
    |   To: lEpoch = length(ThD);
    |     : disp(sprintf('Length of an Epoch: %d', lEpoch));
    |     : epoch = 1; J(1) = 10000; % Initializes epoch and J()
    |
    | From: if( log10(epoch) == floor(log10(epoch)) ), J(epoch), end
    |   To: if( log10(epoch) == floor(log10(epoch)) ),
    |     : disp(sprintf('SumSquardError for Epoch %d: %f', epoch, J(epoch)));
    |     : end
    | % You can also choose a different test condition: I just wanted to
    | % print the SSE after 1, 10, 100, ... epochs. But pick whatever interval
    | % you desire.
    |
    | Delete: if( epoch == 10 ), pi, end
    | % (it was just there to tell me the program was working)
  3. You can clear out most of the variables to save memory; just make sure you keep a copy of the weights (W).
  4. Create a new 30 x 1 matrix Xes by executing Xes = zeros(30,1);
  5. Run ani_cntr.m: This will now simulate the ANN.