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

    function [Y,Xf,Af] = cal_Zo_C(X,~,~)
%MYNEURALNETWORKFUNCTION neural network simulation function.
%
% Generated by Neural Network Toolbox function genFunction, 19-Apr-2015 16:29:44.
% 
% [Y] = myNeuralNetworkFunction(X,~,~) takes these arguments:
% 
%   X = 1xTS cell, 1 inputs over TS timsteps
%   Each X{1,ts} = 2xQ 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 = [0.5;700];
  x1_step1_gain = [0.571428571428571;0.00333333333333333];
  x1_step1_ymin = -1;
  
  % Layer 1
  b1 = [-7.8933517538753408;-9.7608564132247277;-6.6644005256276513;5.4266901485997634;-5.7083959281807104;5.2071107877819358;-4.9949141982791589;-2.2610846927790789;3.9208191999956785;-3.5380196890009823;2.6622084331770774;-1.0439422802297182;-0.76284951022674252;-0.59948861915781604;1.4373878650472678;-0.29873811467296163;0.96014452232024339;1.0967701594177584;1.954301339266886;5.0046352666908005;2.8237348562721856;-3.5662794706518985;3.8988283829968204;-4.7732413352349283;5.2684956143369206;-4.500944689970777;-6.8711820261903167;6.028283547118642;-7.2396607042857619;-7.3477834223840528];
  IW1_1 = [4.4755904093132726 5.8717408063961836;8.3802857216233768 -0.085901649049551637;6.9430243055522451 -1.8899584955476463;-3.6282489944095233 -7.0962736883125777;6.9905114284590839 1.7919939477866593;-5.884105704371172 -3.8202264239652917;15.243249223887794 0.0079035782183584421;6.7735650130986329 0.053525502432761253;-7.0477732156108512 -0.62489378491257797;3.8324032336165126 -5.276972847410077;-5.5198828113105138 -4.6379514039927212;3.1100749219137249 -6.7260284604851153;3.426633871421513 -6.7157807175308744;-5.2854901762625186 -0.0239158246125191;-3.0284487823049919 -5.7542901533890456;-5.2992873238586631 4.6475153996324368;1.9478783765051029 -5.1280962138589983;2.6931305559662775 6.7862861991322143;4.1005561809025117 5.0621114543145422;39.701687015819672 -0.0058819991416315612;6.1913529026388501 -4.3968634372700572;-1.3754063359026023 -6.6277053149877982;1.5324174086302043 7.2525886596401099;-3.2849631460313096 -6.3437515037735519;5.0450527538755834 -5.2990422210763954;-4.0552813112324406 5.204826121513312;-3.8208069773572677 5.3904480783482986;1.1631912370041342 6.6751784133635779;-1.6133398166926185 -8.0059414976507188;-7.2623217123348658 1.9673778491853935];
  
  % Layer 2
  b2 = [-1.8512684182622645;-0.0065538911780274184];
  LW2_1 = [-0.051292833369808728 -2.1715634817158898 -0.021025121646225622 -0.0041936182971111305 0.10106109330543256 0.09863109479726638 -0.89434183393811273 1.0697841005359841 -0.14060216757012381 0.023583716780305332 0.033673334497516201 0.044950724363542395 -0.035721258452999179 -0.48372228778325016 0.022479751302358159 -0.010538207878064768 0.03384101102426567 -0.035722649223597608 0.0065124580425895626 -0.68769456245016469 -0.0014093439340028451 0.29770441925856017 0.22293109211308532 -0.023631474792563802 0.01286731517592467 -0.022551475757322102 -0.03433031724811083 -0.36481615017566354 -0.26933370538448581 0.020210582904455345;0.1104190476042137 -0.077526315084093092 -0.03389271135630572 -0.052314975295503191 -0.056494885575851743 -0.098356954469915145 0.004717008936511613 -0.039279036499847278 0.027190364948430655 -0.054158351872002859 -0.042978668683309955 -0.11642247029342136 0.080678778565851247 0.014871609595948581 -0.10731376467495561 0.028164695123081434 -0.085379054363089388 0.10483161184743288 0.019055203399596956 -0.00090308875111813852 -0.013171285294322469 -0.62640831902203098 -0.44350801681032187 -0.0016836424157301265 0.044090814606399874 0.1181029949070629 0.078747278123267248 0.63482770318025639 0.37591829974204211 -0.0031382043874961501];
  
  % Output 1
  y1_step1_ymin = -1;
  y1_step1_gain = [252.01612903226;625.500400320256];
  y1_step1_xoffset = [4.743496;-0.009877367];
  
  % ===== 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