N = 2000; % number of samples train_frac = 0.75; % percentage of values to use for training u = 0.9; % constant for Ikeda map x = 0.3; % initial x value for Ikeda map y = 0.3; % initial y value for Ikeda map epochs = 500; % number of epochs to train the network for goal = 1e-10; % performance goal % end index of training values, train_index + 1 is where testing begins train_index = ceil (N * train_frac); % 2-column input matrix P = zeros (2, N); P(:, 1) = [x y]; for n = 2:N t = 0.4 - 6 / (1 + x^2 + y^2); x_tmp = 1 + u * (x * cos (t) - y * sin (t)) ; y_tmp = u * (x * sin (t) + y * cos (t)) ; x = x_tmp; y = y_tmp; P(:, n) = [x y]; end % normalized version of the time series, now mapped between -1 and 1 P(1, :) = mapminmax (P(1, :)); P(2, :) = mapminmax (P(2, :)); % build a new feed forward back propagation network net = newff ([-1 1; -1 1], [10 10 10 2], {'tansig' 'tansig' 'tansig' 'purelin'}); % train the network net.trainParam.epochs = epochs; net.trainParam.goal = goal; net = train (net, P(:, 1:train_index), P(:, 2:train_index + 1)); P_out = P; % test the network P_out(:, train_index + 1:N) = sim (net, P(:, train_index:N - 1)); % get mean square error e = P(:, train_index + 1:N) - P_out(:, train_index + 1:N); mse (e) figure (2); plot (P(1, train_index + 1:N), P(2, train_index + 1:N), P_out(1, train_index + 1:N), P_out(2, train_index + 1:N), '.-'); xlabel ('x'); ylabel ('y'); title ('Target vs. Experimental Neural Network Ikeda Series'); legend ('Target', 'Experimental');