www.gusucode.com > matlab编程遗传算法计算匹配电路源码程序 > code1/code/MATLAB源代码/cal_Z22_L.m
function [Y,Xf,Af] = cal_Z22_L(X,~,~) %MYNEURALNETWORKFUNCTION neural network simulation function. % % Generated by Neural Network Toolbox function genFunction, 19-Apr-2015 19:56:46. % % [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 = [13.063460202164709;-11.097139366265031;-9.4337754654308466;-5.3665050872360958;-6.1923746408924103;-5.950496241643183;4.3034232302319984;3.7235711905163358;4.5175875479846725;-2.2568743882388733;-1.6153871053060012;-1.3999732133804632;0.22811980918200073;-0.60355839272933964;-1.2117031916201646;2.3436192510236586;3.4438679399378938;1.1957728164840946;4.859066581344833;4.5655376303723187;4.9218380718554995;-7.8762897131703271;-7.1119058603415857;-7.7981561271116542;10.188378082821652]; IW1_1 = [-12.34741052721149;11.353288730630389;10.305327486424249;6.382917307503277;8.405105752162001;8.9038523655722557;-7.266389103098815;-7.5165224610913048;-10.623302503779595;6.0087858035489452;6.4786493716171565;9.0551716511349305;-2.7367601715224352;-8.2132802731690084;-7.0829819538514558;9.0509752218665263;10.381828173605216;2.2975716836793789;8.9448757390362843;7.1923461866311182;6.5373610652705638;-9.7125005092350118;-8.0678954442282382;-7.9870275411446832;9.3675977270935871]; % Layer 2 b2 = [0.23800982155891082;-0.14153946348128527]; LW2_1 = [-0.0064584969890686041 0.0032805468542645828 0.0017188343191113567 0.005987965915730321 -0.00069028136465621218 6.200477797925579e-05 0.0025146439642186741 0.0022597010528151934 0.00029657539199211296 -0.0049599837746620093 -0.00071366832813506815 0.00090492395267206501 0.13819143057103539 0.0017925505628070412 0.0045665096804781919 -0.00054911072314785768 -5.0347923267513902e-06 -0.66219801903434361 -0.0038468631780834324 -0.019791087250490863 -0.085188735052212847 0.0093799031845688483 0.066096689489991658 0.10550701098067643 -0.12693375094941517;-0.026866546197858998 0.014304325440058743 0.0090582827572346022 0.060784529896264705 0.015069100758916921 0.010994384651370757 -0.031659383151391024 -0.019826993871773876 -0.00096977763325294293 0.034771765702627216 0.0098119299744540561 0.00051498195872204996 -0.2154191774539081 -0.001066508727396241 -0.0046701493381682609 0.0013165905099014564 0.00041207870633615885 0.45564184625878262 0.0011075335876905574 0.010669188066450182 0.051495539341026547 -0.0067638753588222956 -0.04395971994024702 -0.077474055290526894 0.11209999207582959]; % Output 1 y1_step1_ymin = -1; y1_step1_gain = [71.3452503683199;0.0092255433153097]; y1_step1_xoffset = [0.1478672;-403.1936]; % ===== 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