function [y1] = net_248_ExpNr_tiny(x1)
%NET_248_EXPNR_TINY neural network simulation function.
%
% Generated by Neural Network Toolbox function genFunction, 20-Jun-2018 08:55:29.
% 
% [y1] = net_248_ExpNr_tiny(x1) takes these arguments:
%   x = 6xQ matrix, input #1
% and returns:
%   y = 2xQ matrix, output #1
% where Q is the number of samples.

%#ok<*RPMT0>

% ===== NEURAL NETWORK CONSTANTS =====

% Input 1
x1_step1.xoffset = [-0.28471799347;0.00433333333333;251.0158335;1;-14.3290262092;0.0425265];
x1_step1.gain = [2.47072442491281;2.38884094898727;0.033549072601728;2;0.0718995946647783;0.10598849012692];
x1_step1.ymin = -1;

% Layer 1
b1 = [2.7403474190875298788;-0.91381912717139424096;-2.2293316572600039294];
IW1_1 = [3.2395575803739316001 0.66425074544504703056 -0.44263556470061304893 -2.7821679284251166209e-05 0.71256216540306294149 1.1649843799746206763;-0.49121709391775508768 0.0910102866943042349 -0.20148547199407504382 -1.078124165754202668 1.1532954399272352664 1.2344899380294425129;-3.4164715986521030366 1.9032110608512282646 -0.12799618663851286549 4.3430503249754490724 -2.1695762656323367423 2.4474779768753660569];

% Layer 2
b2 = [0.0178405907025257493;-0.44530222740112479496];
LW2_1 = [-0.14782195327994235301 0.36177246808004576151 0.50892200207044846483;0.25998495407164035065 -0.14016799887479897135 -0.070938318639079567252];

% Output 1
y1_step1.ymin = -1;
y1_step1.gain = [1.06091734339932;0.502996472181491];
y1_step1.xoffset = [0.020989;-1.65792497728];

% ===== SIMULATION ========

% Dimensions
Q = size(x1,2); % samples

% Input 1
xp1 = mapminmax_apply(x1,x1_step1);

% Layer 1
a1 = tansig_apply(repmat(b1,1,Q) + IW1_1*xp1);

% Layer 2
a2 = repmat(b2,1,Q) + LW2_1*a1;

% Output 1
y1 = mapminmax_reverse(a2,y1_step1);
end

% ===== MODULE FUNCTIONS ========

% Map Minimum and Maximum Input Processing Function
function y = mapminmax_apply(x,settings)
  y = bsxfun(@minus,x,settings.xoffset);
  y = bsxfun(@times,y,settings.gain);
  y = bsxfun(@plus,y,settings.ymin);
end

% Sigmoid Symmetric Transfer Function
function a = tansig_apply(n,~)
  a = 2 ./ (1 + exp(-2*n)) - 1;
end

% Map Minimum and Maximum Output Reverse-Processing Function
function x = mapminmax_reverse(y,settings)
  x = bsxfun(@minus,y,settings.ymin);
  x = bsxfun(@rdivide,x,settings.gain);
  x = bsxfun(@plus,x,settings.xoffset);
end
