gusucode.com > matlab编程遗传算法计算匹配电路源码程序 > code1/code/MATLAB源代码/cal_Z12_L.m
function [Y,Xf,Af] = cal_Z12_L(X,~,~) %MYNEURALNETWORKFUNCTION neural network simulation function. % % Generated by Neural Network Toolbox function genFunction, 19-Apr-2015 19:51:51. % % [Y] = myNeuralNetworkFunction(X,~,~) takes these arguments: % % X = 1xTS cell, 1 inputs over TS timsteps % Each X{1,ts} = 1xQ matrix, input #1 at timestep ts. % % and returns: % Y = 1xTS cell of 1 outputs over TS timesteps. % Each Y{1,ts} = 2xQ matrix, output #1 at timestep ts. % % where Q is number of samples (or series) and TS is the number of timesteps. %#ok<*RPMT0> % ===== NEURAL NETWORK CONSTANTS ===== % Input 1 x1_step1_xoffset = 700; x1_step1_gain = 0.00333333333333333; x1_step1_ymin = -1; % Layer 1 b1 = [19.62622144765999;12.826104714792104;-13.489322848647904;7.8342406267040543;-7.3555864164050693;8.7232251303713433;-7.4002874776575291;-5.9978957823636048;-4.2467193769667686;-4.3387003263358048;-3.7323515871801973;2.8365047248096404;-2.9459945170299626;-1.5440317635566971;1.0367733860282635;0.029002552306127694;-0.97995008235525494;1.6842055924718768;-3.2178121302761014;2.9257149709404615;-2.7139419339281732;2.4392831489976365;5.2927872056461887;6.2866686044533537;-8.3924268173202314;-7.3709082594865878;-6.0405909189321489;11.119580933563583;-9.8099303485911449;-14.860128183379528]; IW1_1 = [-18.999910868023999;-13.158155936582729;14.739673425047554;-9.0771915673109689;9.5653690832838176;-12.266829909438039;11.20897448320995;9.9834866248517216;8.1651025710034872;9.8702944958711782;9.9605690754563714;-9.3593965493313114;12.17061101506801;8.1731262663863635;-10.592742348961039;3.4399118780395912;-8.9658020349989584;8.5891317368640152;-13.127677776534624;9.9422328740113084;-7.4627028678307878;4.7838149851956615;8.9655151722555679;9.5488413630937146;-11.842166021626426;-9.6945759685851076;-7.0500990757824304;12.147346590902227;-9.9339490318874724;-13.98863506264995]; % Layer 2 b2 = [0.052215982678786944;-0.10318487083304649]; LW2_1 = [0.020696597195128945 0.029027221033970211 -0.006633098442427922 0.048919351789653072 -0.033946615017256258 0.0095419850461757726 -0.016747847669358711 -0.021762246730314239 -0.046601027932203345 -0.017155400118207122 -0.017882091676417779 0.022860911371491384 -0.0028704093219302381 -0.021560417262555819 0.0018865053171567188 -0.23793442180552596 0.0049072881482077908 -0.019871855895179018 0.0017624817369802119 -0.010496284072370434 0.02852474593359217 -0.18034100619440199 -0.01335612719058254 -0.026442596605898545 0.0075188676864031741 0.027511435939960194 0.12244906416936774 -0.0069947780019681731 0.063009563424577128 0.044806549132008856;-0.012070986983540626 -0.018031413316873312 0.0041987070352026744 -0.033158846051196553 0.025110705963783411 -0.0071870883070962082 0.012923565317945012 0.017066336262635245 0.03834352485168524 0.014692275507783599 0.015344948784220156 -0.020016036653453858 0.0024679220808807392 0.018954689582903483 -0.0014135441242759113 0.23047431886744266 -0.0054279268478034295 0.020490660182077812 -0.0017924811419722133 0.010909160234649879 -0.028827486576062822 0.19246432637572283 0.015647651491618869 0.029925430411725133 -0.0089446318496603072 -0.031131220829256418 -0.1523815057504119 0.0098959032987716161 -0.089405214002283684 -0.072362940231509812]; % Output 1 y1_step1_ymin = -1; y1_step1_gain = [25.4803751424672;0.0109757255366169]; y1_step1_xoffset = [0.01789064;-437.9664]; % ===== SIMULATION ======== % Format Input Arguments isCellX = iscell(X); if ~isCellX, X = {X}; end; % Dimensions TS = size(X,2); % timesteps if ~isempty(X) Q = size(X{1},2); % samples/series else Q = 0; end % Allocate Outputs Y = cell(1,TS); % Time loop for ts=1:TS % Input 1 Xp1 = mapminmax_apply(X{1,ts},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 Y{1,ts} = mapminmax_reverse(a2,y1_step1_gain,y1_step1_xoffset,y1_step1_ymin); end % Final Delay States Xf = cell(1,0); Af = cell(2,0); % Format Output Arguments if ~isCellX, Y = cell2mat(Y); end 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