function [y1] = simulateStandaloneNet(x1) %SIMULATESTANDALONENET neural network simulation function. % % Generated by Neural Network Toolbox function genFunction. % % [y1] = simulateStandaloneNet(x1) takes these arguments: % x = 1xQ matrix, input #1 % and returns: % y = 1xQ matrix, output #1 % where Q is the number of samples. %#ok<*RPMT0> % ===== NEURAL NETWORK CONSTANTS ===== % Input 1 x1_step1_xoffset = 0; x1_step1_gain = 0.200475452649894; x1_step1_ymin = -1; % Layer 1 b1 = [6.0358701949520981;2.725693924978148;0.58426771719145909;-5.1615078566382975]; IW1_1 = [-14.001919491063946;4.90641117353245;-15.228280764533135;-5.264207948688032]; % Layer 2 b2 = -0.75620725148640833; LW2_1 = [0.5484626432316061 -0.43580234386123884 -0.085111261420612969 -1.1367922825337915]; % Output 1 y1_step1_ymin = -1; y1_step1_gain = 0.2; y1_step1_xoffset = 0; % ===== SIMULATION ======== % Dimensions Q = size(x1,2); % samples % Input 1 xp1 = mapminmax_apply(x1,x1_step1_gain,x1_step1_xoffset,x1_step1_ymin); % 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_gain,y1_step1_xoffset,y1_step1_ymin); end % ===== MODULE FUNCTIONS ======== % Map Minimum and Maximum Input Processing Function function y = mapminmax_apply(x,settings_gain,settings_xoffset,settings_ymin) 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_gain,settings_xoffset,settings_ymin) x = bsxfun(@minus,y,settings_ymin); x = bsxfun(@rdivide,x,settings_gain); x = bsxfun(@plus,x,settings_xoffset); end