function [y1] = myNeuralNetworkFunction(x1) %MYNEURALNETWORKFUNCTION neural network simulation function. % % Auto-generated by MATLAB, 17-Jul-2024 14:28:21. % % [y1] = myNeuralNetworkFunction(x1) takes these arguments: % x = Qx3 matrix, input #1 % and returns: % y = Qx1 matrix, output #1 % where Q is the number of samples. %#ok<*RPMT0> % ===== NEURAL NETWORK CONSTANTS ===== % Input 1 x1_step1.xoffset = [0;0;0.003608037]; x1_step1.gain = [2;2;2.51275537131268]; x1_step1.ymin = -1; % Layer 1 b1 = [-3.0569652147100017103;-2.3008728962092384052;-2.0234786298460591958;0.96367077971546766246;-0.81534448840778794843;-0.28135504611674383435;-3.1713369473263730569;-1.3633978750254183154;2.3603289291814131268;1.890499188743694825]; IW1_1 = [1.081693732573163258 2.3901733267435356645 -1.4383502767355504925;2.2187514472589104919 -1.9232469067512969474 3.4123632436933362122;0.31239650370167815208 2.9654649089014450958 -1.1112321527076849392;0.43255153316734989977 3.0054254492702954238 3.6099560712683484986;-2.2303910936554114386 -1.0670112398495823491 -0.93613423799071526776;4.4168946601613763292 -2.9141261222490042471 2.7775589356718537459;2.8376150421228616416 -3.959852729174976993 -5.5448117415121878082;-2.5598089596907560583 1.3136000661186457705 1.083177590825957326;1.1377527751024392177 -2.0213105446169969959 -2.393266283426690233;2.7620388738459551448 0.54822583410881042809 1.7356568488795645067]; % Layer 2 b2 = -0.81795751086553836195; LW2_1 = [0.15407289478123287196 1.3150978697907702575 -1.1821568926530159338 -3.02082481091273225 1.4604258145050390549 -1.3230490360304167918 -2.5352230632656702625 -0.43051814558099743557 -1.3861219667418245294 2.1291571835705953575]; % Output 1 y1_step1.ymin = -1; y1_step1.gain = 2.22222222222222; y1_step1.xoffset = 0; % ===== SIMULATION ======== % Dimensions Q = size(x1,1); % samples % Input 1 x1 = x1'; 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); y1 = y1'; 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