function [error] = getError(esn, freq, plotGraphs)
%UNTITLED1 Summary of this function goes here
%  Detailed explanation goes here

%plotGraphs = false;

nSeqLength = 1200;
%output = sin((1:nSeqLength) / 4) / 10;
%output = output ;

[input output] = generate_freqGen_sequence(nSeqLength, 14, 30, 200);  %14, 26, 200);

output = 2 * output - 1;
output = output / 2;

plot (1:nSeqLength, [input output]);

esn = create_esn(1, 200, 1, 20, 0.8);

esn = scaling(esn, 0.4, 1, 3.5);      
                    %(esn, 2.5, 1, 5) (esn, 0.5, 1, 1.4)
plot([input output]);
%output = sin((1:nSeqLength) / 4) / 2;
%output = output ;


if (plotGraphs)
    figure(1);
    plot(teacher);
end

% train network
[nos ir esn] = train(input, output, esn);
if (plotGraphs)
    figure(2);
    plot(1:length(input), ir(1:5, 1:length(input)));
end

% test run
[nos2 ir error esn] = runNetworkWF(nTestSeqLength, output, 200, esn);
if (plotGraphs)
    figure(3);
    plot([nos2' output']);
end


