gusucode.com > matlab编程遗传算法计算匹配电路源码程序 > code1/code/MATLAB源代码/cal_Zo_L.m

    function [Y,Xf,Af] = cal_Zo_L(X,~,~)
%MYNEURALNETWORKFUNCTION neural network simulation function.
%
% Generated by Neural Network Toolbox function genFunction, 19-Apr-2015 20:00:13.
% 
% [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 = [-9.8890944076367422;-4.9736960226797784;-3.0705349816636174;-1.2289253130807465;-0.70571640808788005;0.40655442152251936;-1.8406140246015101;-2.5265715191159108;-4.6461740720535953;-7.1323229570309596];
  IW1_1 = [9.9821807397532965;5.9368011918969872;4.8896681613460649;3.513061097001223;6.1924597400622821;3.1869214719650527;-4.7430721808012866;-4.0442136777496511;-5.5154220914886745;-6.8914731736790786];
  
  % Layer 2
  b2 = [0.19295307305043272;-0.10477342801186607];
  LW2_1 = [0.00039167604764110252 -0.020862589589201942 -0.028763285814839258 -0.11144967190286859 -0.016357153008490773 -0.23874758536911325 0.08931078919788854 0.25697938256691316 0.18874598150697974 0.24314973056300815;0.035662617707881449 0.066779792102397401 0.0697956364200851 0.163250754771953 0.02044232179608103 0.23483822337099133 -0.070838315243903882 -0.20176470517699874 -0.13125158892839756 -0.16639490840255633];
  
  % Output 1
  y1_step1_ymin = -1;
  y1_step1_gain = [125.786163521884;60.0117442983592];
  y1_step1_xoffset = [129.398;-0.1090372];
  
  % ===== 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