gusucode.com > matlab编程遗传算法计算匹配电路源码程序 > code1/code/MATLAB源代码/Odd_even_mode_impedance_calculation.m
function [Y,Xf,Af] = Odd_even_mode_impedance_calculation(X,~,~) %MYNEURALNETWORKFUNCTION neural network simulation function. % % Generated by Neural Network Toolbox function genFunction, 06-Apr-2015 12:34:23. % % [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.2;0.2]; x1_step1_gain = [0.526315789473684;1.11111111111111]; x1_step1_ymin = -1; % Layer 1 b1 = [-5.7037154456209525;-6.7658280565186564;6.3288680814659051;1.6778568168638899;-0.3944564840366106;3.014638563900359;4.5505142505147553;-3.3234679556470086;1.3011214888876965;0.14335785282650154;-0.7044882910150333;0.08226042725649059;2.7368179657890512;-3.4321301164400682;4.8762454835965023;-2.8593315377865358;-1.1846450091560594;9.1354718250688585;9.0822568540949398;5.571309229921841]; IW1_1 = [5.2356760936014197 1.4806279595884464;-3.5032838061892151 -1.8757019105590049;-4.238044424027759 2.8141202595132642;0.70287633715043729 0.36392129223630926;2.6193135976871078 1.0577200208577848;-3.2281237179420774 1.7988107996493059;0.12735935393511646 3.5260194998109506;-0.35208488185004372 -2.6142629954037764;0.84313778975673392 0.43095132213404186;0.51173250364539324 -0.00030794469819358269;-1.3908855685950952 -0.0061551929560176169;1.068131909871417 -2.0083929901681397;5.3065267697884382 0.30213694314747913;-0.3846718488826058 -1.9430699078484273;3.0051037670964358 -4.8152678551487726;-1.9641426979556664 -0.01141419437288794;-0.66181225821583589 0.20339466612044896;7.4663642118666784 0.0099031951940384468;6.1688526157644441 1.0823266791273651;1.6067183651067642 -4.6781450409832654]; % Layer 2 b2 = [8.3948020603436451;-4.5702257000244311]; LW2_1 = [-0.0010864963859898308 1.0391467733886226 -0.00030634037754204363 -3.9371747892455398 0.0015763444975418366 -0.0001413756823692956 0.0020359438864845109 -0.0083602092230220127 1.1644443522381265 -0.25661191025614394 0.076129189768583544 -0.00072820625295427115 0.0018331188564367164 0.055643090473396495 0.00027853656770443784 2.1380682954809367 0.23904772803587046 -1.7617211321348449 -1.2174896685446281 0.00082715110298097003;0.0022777621609534129 -1.1335237076723683 0.00059276640069560993 6.7408339951271463 -0.0035179750644060903 0.00027938141156019742 0.14404901230234629 0.28304779508728056 -2.0798724482870923 -0.76323435796923056 0.25782926418301172 0.00049150716227597507 -0.0021712968720709763 -1.8122732085398749 -0.00011051106687554849 3.6582975485178353 -0.28359390076981134 -2.2578124105960891 2.5941844010076971 -0.00088226882721887626]; % Output 1 y1_step1_ymin = -1; y1_step1_gain = [0.0115809301455665;0.0186518272728884]; y1_step1_xoffset = [35.6393;26.4179]; % ===== 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