www.gusucode.com > matlab编程遗传算法计算匹配电路源码程序 > code1/code/MATLAB源代码/cal_Z11_L.m
function [Y,Xf,Af] = cal_Z11_L(X,~,~) %MYNEURALNETWORKFUNCTION neural network simulation function. % % Generated by Neural Network Toolbox function genFunction, 19-Apr-2015 19:49:22. % % [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 = [-15.705753999398985;-13.887300509419468;7.8126125391654098;6.6251218566127967;-4.0448957716962699;-6.4231833251082557;-2.4139011980202176;-2.093415704590802;-1.0696865118591234;-0.71029984402622215;0.062131102757494019;0.35658143582061996;1.3108419141045764;-5.0173626372525035;1.1048901767957102;5.4667947783217592;5.8396409791062354;-6.8432177912726351;-11.530690019523124;9.8436914349573463]; IW1_1 = [15.251081761554635;14.450334210147247;-8.6222987293339237;-8.2237706974103055;5.7882546247516569;10.945004178991775;4.8039674590659294;5.9708906505660027;5.1050310284409397;7.5021153554389883;-7.9507404258007792;4.5341249983486902;4.8024512314694734;-12.581455020317833;1.6400758936235444;8.132780438099795;7.4875959748098557;-7.6314973622849145;-12.066629524794301;9.2588889299056447]; % Layer 2 b2 = [0.35505113365590579;-0.24052277136622344]; LW2_1 = [-0.012878027945288348 0.012564664105162321 0.00086274514437456476 -0.0080446136947364254 0.0010750926582705192 0.0015643509752782563 -0.011046798245311185 -0.0035359702668208747 -0.02482496197700854 -0.0024394395523729862 0.0039917622089412057 -0.03036348170432281 -0.018619734635075914 0.0068722837994901398 -1.043581439453225 -0.03771779950476184 -0.0013538529995929468 0.092982351825588047 -0.0061507232873094344 -0.10443384724538569;0.02083510182653027 0.0074239955020688119 -0.033875850108423339 -0.017722572876209979 0.054406406077271492 0.00093647016587870792 0.077811193392926151 0.02348371463903378 0.060248204489621843 0.009168845523787026 -0.005126955570794285 0.056799857099526112 0.017766924583748372 -9.4711773610549191e-05 0.7681031959117014 0.0024374123984771219 0.012425690532761048 -0.037043510019961083 -0.0077644580486509523 0.083881295581029941]; % Output 1 y1_step1_ymin = -1; y1_step1_gain = [73.2289576590167;0.00920466197719821]; y1_step1_xoffset = [0.1468925;-404.1079]; % ===== 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