How can i simulate my trained time series neural network?
1 view (last 30 days)
Show older comments
Fabián Flores
on 11 Jun 2021
Commented: Fabián Flores
on 14 Jun 2021
My model consists of an (1xInput) input (voltage) and (1xOutput) output (angle of an arm), after training the network and generating the function to simulate the model, it asks me for 2 inputs (2xTs) with their respective delays.
What is this additional input and delay this function is asking for?
function [Y,Xf,Af] = Simular_Brazo(X,Xi,~)
%SIMULAR_BRAZO neural network simulation function.
%
% Auto-generated by MATLAB, 11-Jun-2021 00:52:39.
%
% [Y,Xf,Af] = Simular_Brazo(X,Xi,~) takes these arguments:
%
% X = 2xTS cell, 2 inputs over TS timesteps
% Each X{1,ts} = 1xQ matrix, input #1 at timestep ts.
% Each X{2,ts} = 1xQ matrix, input #2 at timestep ts.
%
% Xi = 2x11 cell 2, initial 11 input delay states.
% Each Xi{1,ts} = 1xQ matrix, initial states for input #1.
% Each Xi{2,ts} = 1xQ matrix, initial states for input #2.
%
% Ai = 3x0 cell 3, initial 11 layer delay states.
% Each Ai{1,ts} = 20xQ matrix, initial states for layer #1.
% Each Ai{2,ts} = 20xQ matrix, initial states for layer #2.
% Each Ai{3,ts} = 1xQ matrix, initial states for layer #3.
%
% and returns:
% Y = 1xTS cell of 2 outputs over TS timesteps.
% Each Y{1,ts} = 1xQ matrix, output #1 at timestep ts.
%
% Xf = 2x11 cell 2, final 11 input delay states.
% Each Xf{1,ts} = 1xQ matrix, final states for input #1.
% Each Xf{2,ts} = 1xQ matrix, final states for input #2.
%
% Af = 3x0 cell 3, final 0 layer delay states.
% Each Af{1ts} = 20xQ matrix, final states for layer #1.
% Each Af{2ts} = 20xQ matrix, final states for layer #2.
% Each Af{3ts} = 1xQ matrix, final states for layer #3.
%
% 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 = -4;
x1_step1.gain = 0.250000000000001;
x1_step1.ymin = -1;
% Input 2
x2_step1.xoffset = -1.22568411949813;
x2_step1.gain = 0.882802087508233;
x2_step1.ymin = -1;
% Layer 1
b1 = [0.00079290479943929263393;0.1305572645190053449;-0.016716733883341550193;0.039441836090246901181;-0.0082309933022506661521;0.0075823868718269569686;0.0047321385856114520085;0.057033707788083587431;0.14737031574700668046;3.2286947369939314836e-05;-0.070775393047497317522;0.1476821968233786031;0.021780475237721266812;-0.0056876548691055508686;0.013009287579592191536;-0.00077692643760469168139;-0.012256229152082494596;0.0035434151785441380875;-0.023530045312407599223;0.013971772563190151123];
IW1_1 = [0.00067087380741671952863 0.00020704268333290612946 -5.1237304984196559219e-05 -0.00015265340676941235995 -5.1193127640646874635e-06 -0.00019962850103916280286 -4.7455494842273642083e-05 3.7574419234254912738e-05 -9.7731743063562574519e-05 -0.00027191800431793902628 -0.00034344099757131264262 2.7634214563509117667e-06;-0.017373887646530288692 -0.037591437506898528476 -0.014774103732526569152 -0.024478814095779035526 -0.015803729389895555812 -0.019303957973309027185 -0.020826207593853163919 -0.015070634356991040315 -0.0085043855076501612134 -0.0057531534064110441407 -0.0010225964729650858977 0.0017033496283741405338;0.0044518081916348015842 0.014981716980332111452 -0.0028922130953937742921 0.012244063255659827852 0.0010482020463426354896 0.013242033944280412819 0.018690671113994358071 0.0081795722766231093726 0.0013497194188876158755 0.01549095481851686662 0.017943322087871412668 0.026926077407902735544;0.0045368650120229331649 0.018910942237425360651 0.012800505562106389429 -0.0087928087551139653272 0.0080318663722130038268 0.0037612637240247398344 -0.0062078747018898235502 -0.0249768084043917038 -0.010814879129776485897 -0.020079278191379185819 -0.027482578765991513836 -0.037485813305203410928;-0.0054544524557494176303 -0.0017987876253453747005 -0.0087160702634079701562 -0.019133242932411247128 -0.016670732229097970367 -0.010630861153091024363 -0.0023184574868607863915 0.0081282870271839214454 0.0055253072291077641454 0.017396827611438965555 0.013334769842838680581 0.017925735334431876222;-0.00010976111668376994088 0.0077914942902010076928 -0.0043835824101325845947 0.0075247348207965946906 -0.002653045968494908112 0.0047587042775379170129 0.0061116087863617458292 0.0044576744902853210339 -0.0015709410742585337446 0.009869618131584363338 0.0059572112723254916009 0.0074906183072620856692;0.004533400727937068192 0.0070985723660795755491 0.00032874713667265230985 -0.0096846558053707062358 0.0098964086740860133379 0.0033014066000058451406 0.00057669795766027338608 -0.0025152652748266089884 0.0077280725334721855901 -0.0097729235507360238261 -0.0059944136697777676212 -0.011862828855404884687;0.00049598232842833786613 -0.0026155785470582866049 0.0044222605801983502077 -0.0017820910136253976554 0.0003711006528492402385 5.0767182862341063518e-05 -0.0031880320565259544219 -0.0029543651612382228894 -0.0038356474677841913452 -0.0069892182265558931362 -0.0056682299768617879637 -0.008398439833632934115;0.013516097473595597989 0.01676033128032176564 0.032470328910678886158 0.016440540760665842829 0.022410132883738168724 0.0048414560748075534391 0.00049543272677563844619 -0.012518765012257697736 -0.0018253580468546408422 -0.027681157085400389523 -0.04106796450577419183 -0.04062363486169801724;3.7045873624562301667e-05 -0.00030747056400846201323 -0.00047187611328028096838 0.00038877874005842534555 0.00011090689932541480923 0.00083065426676503281277 0.0008177927674100383135 0.0019098944764453945101 6.1115948106653408237e-05 6.0779865879660922206e-05 -0.0013618561137289529519 -0.0013374541627485182944;-0.022452152502154997665 -0.022739665167637836823 -0.0081350775921706502958 -0.000504823542302899257 -0.0052578629357218839568 -0.0090274365642551944455 -0.0083843094751372901352 0.0048070586625206385145 0.013145161725628856306 0.010763805483768760715 0.007122874123258585155 0.0082160816068455912176;0.0025223241350361435588 0.0056259723481128197375 0.00078231042168743403133 0.0048208420140157049252 -0.00018590529758185441139 0.0049572105678022627614 0.0075779065278420250015 0.0043942484540687165584 0.0005375956320557277214 0.0062380359825682995742 0.0086497408237912413315 0.011745610283559337547;-0.0090387800748789465244 -0.0052027049586229603614 -0.011453636793412963479 0.013437972200899943667 -0.0084895426939029863811 -0.0012675703758645792425 0.0014020595755194673569 -0.0012329927594266465972 -0.0075109174632013971443 0.0139938298485361972 0.0022793793673502441878 0.013181853727888099073;-0.0041610364288221981383 -0.0079892534360357543577 -0.0011790621662487871246 0.010919052722943026895 -0.01257885664415666141 -0.0045245579351171428054 -0.00081297959023069604756 0.0032328740088762536291 -0.0093872487970512886318 0.012224135853640015134 0.0072940635193692081664 0.014621644306201464839;0.0045428100396301442088 0.0048166175204796650433 0.0031096464882440651677 0.0033042227439594763772 0.0039830725985686007626 0.0079199439924137766261 0.011647197266338230742 0.0023670010019179814863 0.0024625881617194472252 0.0038056732714617964863 0.011593762594883748676 0.019365587296219521213;0.0086983588233284642177 0.014866417850628829353 3.3703547331992620936e-05 -0.003053749649214820925 0.0043474162492943904668 0.011836236307288248645 0.0047923346941034037499 -0.006627246557641990575 -0.0069041699678766398768 -0.0021622747217304770853 -0.0015134817476713704597 -0.0016028929805426879191;-0.016840659964406635291 -0.0032962218305700070886 0.0011208719504524219078 0.019368176836573901267 -5.0671368566499995511e-05 -0.0070154159221482081596 -0.011915883555977077254 0.011119446839393710633 0.0036566625371444168129 0.010576848763413141535 0.0085211816436206455627 0.011348951821814123181;-0.024885962699057347786 -0.036775830987659872962 0.002928554403860402465 0.0086096295343036696041 -0.012609150119944127072 -0.031627777100218863737 -0.013086875015933027017 0.01369521021556849294 0.018477884829170981851 0.0062576235430953277422 0.0068771527382507835133 0.0070271037527190015337;-0.0042789646121386658295 -0.015781329773969392238 0.0032276153663072675894 -0.013906887569234348614 -0.00013201702064709092306 -0.014619485304668406594 -0.020184057821737804578 -0.0087597901538768348229 -0.00022716207331355506055 -0.017751314279948741948 -0.0197233582069421369 -0.029551609287150781835;-0.0037213020965323057032 -0.012491247628477688755 0.0024247396154484920569 -0.010245974223954011292 -0.00089810894208567542199 -0.011101816892655800434 -0.015646744554204828487 -0.0068378464172021251322 -0.0011095554878170911083 -0.012917154050074063087 -0.014978289952937033636 -0.022516478250749712153];
IW1_2 = [0.55819047950489097953 -0.25835362435538705705 -0.38229556713200130158 -0.19640836501062594599 0.0015970407074585080999 0.094331609693016960083 0.10023037260088688005 0.068880860647868413782 0.030516158883139660185 0.003210020002340246547 -0.0034013609845095879765 -0.016001448073560620849;0.2778347461958575737 0.16182254108607566079 0.083240819988889117043 0.028855365133037581826 -0.011770989597731247242 -0.043389079171217995179 -0.066635399116362181715 -0.08124561004999231173 -0.087474843988109521331 -0.085834248438428420447 -0.076995533346333203117 -0.062811462168614565216;-0.86077289662048594998 0.03433511991241921385 0.25402822195639951364 0.14887752667580936294 0.0013696929799426440025 -0.066661120653443983741 -0.061673971811587721681 -0.026093100598727891198 0.0098253320809339635133 0.025521927634210028052 0.010668801353949227892 -0.0098326752884499730306;0.025098105735092177127 0.045315648675939193546 0.052630176629037898894 0.05341908628707431328 0.052536176993394176349 0.051842765386156917928 0.051070864734316753775 0.049492074603300094393 0.046672960582551777098 0.042331454435614854215 0.03631030517800337698 0.029085504046998628819;-0.039899272231535991284 -0.028325739972006522965 -0.018560691035643506197 -0.01029899004905178439 -0.0032626115712373442157 0.0027565974433586453232 0.0079061571310427344178 0.012299441123570949846 0.016050159754098371895 0.019261928220796441236 0.022016167980875217536 0.024402260552443145319;0.4181705712981658718 -0.048980200403416454535 -0.13618339990643657522 -0.061652222768414678689 0.014063812022327730131 0.036251382993527994647 0.022573298980589212581 0.0013162535856828356477 -0.014101504759702614133 -0.016655107087873894517 -0.0015434231241832387094 0.015925833431585965233;0.32535092839018059374 -0.083180388557079973366 -0.16000687356313703091 -0.088785882013479991426 -0.0090695535601236203921 0.026579623989247638804 0.02807335834478053016 0.016913499735438642518 0.003339924567493897118 -0.0079512911526278748364 -0.014658799326808103283 -0.030803295605259087275;0.19415346403057545666 0.090163474726661391179 0.035417954510274435309 0.010816491001625924348 0.0005184303874438076767 -0.0037338017423854453526 -0.0041364678973755146171 -0.0010702647439567981001 0.0046493900066422845854 0.011883180025522879081 0.019193594550672998106 0.023542798521702035935;0.025816633296384779855 0.013430809419343969421 0.015915559979374542532 0.025862459522841906023 0.037762658164269602423 0.049691750179670694798 0.062225733656654257098 0.076405193080354247281 0.092875604473002568162 0.1120908688919898949 0.13437268730516022108 0.15929125268704927287;-0.10590086961420291933 -0.0072289403462536998626 0.033015540526434759838 0.040047284909522487539 0.035177688187915258367 0.028772279448034902144 0.022151285784698132586 0.013925450540813994957 0.0035460022633556484081 -0.0087502563831204603628 -0.022059848295843779986 -0.033052375166197710266;0.026790060702024155043 0.021750317368652367228 0.016662614571852564505 0.011534260693562892186 0.0063712361080244077349 0.0011795238383897190069 -0.0040332411269656323616 -0.0092640522832469675979 -0.014504787074368433175 -0.019750224561507892518 -0.024993577688282121729 -0.03022946068141021958;0.93297183744227640823 -0.18515028757339854759 -0.36700973404400699662 -0.15589470794045304225 0.048648292734782078162 0.11157934145434710016 0.079502834295105392903 0.025459926018281498622 -0.016594400764227159456 -0.030262726196545717411 -0.0047558780432243900546 0.023193924101602300669;0.20937910375025348131 -0.024222153922172209861 -0.069869209460289918856 -0.032714291910488746407 0.0083793681957540343958 0.024217591815281068468 0.020590900869745593776 0.0093644430782017663156 -0.0042945755694623393914 -0.018405096917498996179 -0.032134117656396066209 -0.053755560863843657171;-0.10464146861060850957 -0.046707100423262107314 -0.012115365660731826358 0.0069101383184794256884 0.017165993819138993665 0.022898309355206283161 0.02588300691516328203 0.026435863821520574207 0.024330992956220962725 0.019307955056202953659 0.011547952180319219842 0.0021318609155130457608;0.39783271734844122269 0.056162719695695216549 -0.032889277050983989348 -0.0091919584212236914167 0.023093117126579815884 0.026654047461689200915 0.010729873649700917213 -0.0077656275204019721559 -0.020772574885314795679 -0.024230594935941384555 -0.015638285544730162052 -0.0053877832840703342512;-0.08067231617008115141 -0.022383492001252159459 -3.969980919353941894e-05 0.0032041477657139189918 0.0014356506851120158508 0.0014212520677454104287 0.0037572089516588291595 0.0070941637207253558164 0.010480313463384398343 0.01340241891379226509 0.015918117840496646964 0.01983878263638181802;0.11166191060362271048 0.076677185821643775721 0.048938063751903161658 0.02754626185929147375 0.011585053244755109947 0.00023382416813345048372 -0.0071799847836911522697 -0.011242288401584520433 -0.012488056516001799431 -0.011431672897282351212 -0.0085774151648385747737 -0.0044431468779653465057;0.11107542660186128791 0.076268185946908761963 0.047465385887961439315 0.024096607839402189172 0.0055312930303592251768 -0.0088478401509631595528 -0.019596441799540117307 -0.027180765186549313284 -0.03200898623996706327 -0.034462335759566239957 -0.034909084390596964442 -0.033709059481565266381;-0.91295893562135277399 -0.071238598317655540959 0.1713384712442283242 0.11583790555242741427 0.0074087762841915641085 -0.043895854105501654063 -0.038219739241290705267 -0.0091236074012077932743 0.018534617746230157287 0.028737629626655020187 0.015215135941541542072 0.0018630944762309730942;0.77523927504933443089 -0.089311959391425957411 -0.2511713167421353865 -0.11346723327293074812 0.02804229539156912962 0.071975703911121985401 0.050095483850377757473 0.014090130608378369573 -0.012793941845960939835 -0.02090938785981938039 -0.0050056949016976867717 0.0048814681792059789675];
% Layer 2
b2 = [-0.016390303154156921767;-1.5477097225984222644e-05;-0.28650785495161118499;-0.062044619438524441224;-0.15650632033417130606;0.04437249050947754403;-5.992651310544273313e-07;-0.0009207784960539462096;0.0030365017159792104251;-6.1546161319474511167e-07;-1.1054567756868616547e-05;-0.0099346412998198817268;-0.11204011690680967805;-0.01227127829185436364;-0.047981159256041051864;-0.014420546311961823793;-3.278419512285961262e-07;-2.3172548649264364311e-05;0.0025322237681223839535;-0.19770619660115751337];
LW2_1 = [-0.099558500043941081104 0.035967612305274010431 0.51418169434681015861 -0.020396630991509852315 -0.0010441973886391626991 0.017192994884868816746 0.023799731112069118927 -0.0020265795034358105413 0.026234330955140449521 0.033704448928870804625 0.0014645544139642136753 0.070944255203357065032 -0.018384990141536782654 0.042849766076749173926 -0.064148354836286933245 0.013398487258937523056 -0.00050054718726678525294 -0.0054174310410576784203 0.40247299552590193317 -0.045999485446605072048;1.1076192273595847194e-05 2.0811293553575004108e-07 7.6999286780580994898e-06 2.7569930893796230692e-05 1.5683182264758873834e-05 -2.2134901394235333925e-06 -1.4660405388222975411e-05 -6.1726733140892609352e-07 4.6410277326009897014e-06 4.5762673456675452293e-07 -5.2633343060306962666e-06 -3.7841211733059130953e-05 6.4822894081920828021e-06 -1.6190199009033440561e-05 1.1253541036038028931e-06 3.5169783462811964822e-07 -2.6268711627663771959e-05 -2.4858604411254299948e-05 -1.7478876086139117881e-05 8.498541056504621457e-06;-0.001122404110024829765 0.032325817725069892761 -0.040561528377206876317 -0.018865231456984963426 0.008752085008289908416 0.020674363885886278686 0.00094206110284309114468 -0.053067120942136718209 -0.077675563822129006786 -0.013504477403976746994 0.031045281059792564221 -0.18078467941896445015 0.015431478779171222543 -0.0097785457668956091148 0.018862865596065439555 -0.0098527052128740636588 0.065375877216794983648 0.023406458128440249533 -0.0043093824628616887035 -0.025658543256576675506;-0.01354847913290628536 0.054295344037969116291 -0.012305006005834525848 -4.6472371962474835335e-06 -0.010965348868265082857 0.034714786361581768948 0.051653340295860043774 -0.014354414796650023095 -0.058457088920099438412 -0.0033617263949738168845 0.026885405440588858172 -0.081356024488895728464 -0.014644786269334755802 -0.0098950487155872665634 -0.035060584357226580454 -0.010548560330221954176 0.029938216130204631932 0.046556139439205349029 -0.028231214219297365992 -0.019460622743555523045;-0.023847272367759148742 0.028143833114637181736 -0.041980732918518309793 -0.014869792852267780386 -0.0031664144200341170707 0.014490917277297935342 -0.026619538617597748864 -0.055871976253726168826 -0.10292406117053649883 -0.0088539271649475548981 0.005511620334231931255 -0.16058274995901680726 -0.0045503681207431133718 -0.041655009330329971495 0.00048507888134547718327 -0.037356533684260263828 0.069781818673158482746 -0.01719380110363994893 0.019196332202134708256 -0.095653889174212206048;0.20593741704351775645 -0.022721069398464920769 -0.11383469436408746867 -0.03345180911265838164 0.0093997891706875981443 0.14172849587092908874 0.092065099882490189498 -0.034198593284853522067 -0.042690981991297588527 0.018025132893463718942 0.012025244801172519857 0.24556213547939315101 0.033379806158310140751 -0.042762605743044690421 0.069862795728867652101 -0.0057681779782027473025 -0.010824841824045640729 0.002415320079917543817 -0.12623120476257104761 0.2616839388858501203;3.4714138345553644758e-07 -1.4030039873969081118e-07 -4.5871431576360374075e-07 6.0258326535869793755e-07 -2.1722729402087311327e-07 -4.7078816078243497691e-07 6.5091096118914143988e-07 -2.6189264586463655237e-07 3.7428801745092620007e-07 -7.2186984650487175342e-08 -5.4345379862534449209e-07 -6.5784599899652067614e-07 -2.1833570122843954923e-07 -2.3497573763744411873e-07 -3.1671975098514027918e-07 -1.7460577852945751541e-07 -3.2683525124335750105e-07 -1.2033090402779439668e-07 -6.7572050608866391579e-07 -7.4815621678914330965e-07;-0.00011065647735104660861 -0.00033400948704854279293 0.00039206676132936624582 -0.00032519567624454486475 2.3811047933928459585e-05 -0.00058351441781798153111 -0.00023974989606836543407 -0.00046516827218619634073 -0.00054418430571882316082 1.8409398417908617703e-06 4.5096284509399710546e-07 -0.0010567164858193221332 -0.00027813066100633204898 1.6783015751879355872e-05 -0.00041588153892289318053 1.733269919964854712e-05 -0.00021647349653380703032 -6.9083679832523733487e-05 2.6068957222216725052e-05 -0.00091600796225231281063;-0.0011089194287031780856 0.0011847652072998495452 0.0012232722327954251556 0.00081779584563890922455 -5.0205804416452988557e-05 0.00014211107616187172633 2.3050924383883055423e-05 0.0010777526973316949553 0.0013089350194102093369 -3.6360843856440742494e-05 1.7711104157367677387e-07 0.00096515307631787298093 0.00028591990476222004392 5.4015350577031858771e-05 0.00027447593238929802973 -0.00011074785776315157905 0.00040896369759259960583 0.00035797054468356419212 0.00089317141646409270797 0.00078442032491925716385;-6.4063647518642731541e-07 -4.0760057565595670562e-07 -8.8913745827248506951e-08 7.145484235253318981e-08 -2.3440917747098173664e-07 -3.2531278438416978818e-08 -6.7988593182795831315e-08 -2.1365680348595393776e-07 -3.68728885159395056e-07 5.7675355830150679283e-07 4.8930237317637221725e-07 -1.9975764072760431808e-07 -3.426796925373504918e-07 -3.3667177214714416033e-07 -6.1779155192962489644e-07 1.8558219171267936554e-07 4.4570675106573950294e-07 6.4306811039196012905e-07 -3.0735797967055579828e-07 -1.9378966038591861439e-07;-1.1639449555119265817e-05 3.5520653173948367013e-07 -6.7083504341057853022e-07 1.1491327352108846805e-05 -3.2343856082738697823e-07 3.4798642897494012571e-06 -1.5374490101102515887e-05 5.478189022579000919e-06 1.9176697549248151885e-06 2.2761081668680426287e-06 -6.8710070377279639976e-07 -1.1937362262363809918e-05 -7.1282033313034259527e-06 -1.4010661810112545817e-05 -3.279914648678172607e-06 -2.2702786001492708972e-06 -3.3375206935303538145e-06 5.3201199425684515638e-08 -9.7925437228019630056e-06 -2.7679981139154251876e-06;0.10672923131576796119 0.016542283534421935165 -0.22073927356690059565 -0.0019676162444194232257 -0.014483120062778596926 0.27207751091608717298 0.15018617455484764567 0.036193222752885542692 0.031854261841397529809 0.0094760274177783949262 0.024149895139730013366 0.56340463294479259382 0.10615903534923618046 -0.0079692643235802912427 0.1609665885899624338 -0.0072321418645862048033 0.020024888706720356951 -0.0029860163511061859828 0.014578438441542001733 0.49477372674730046853;-0.66801816404157454699 -0.036093411265300225088 0.47124243168978535712 -0.0030621293323397874402 0.021556000317354655216 -0.046217968461558678328 -0.084092154109106725945 -0.029315272446290421143 -0.041214246062017546868 0.070696427759500121701 -0.045086694382742889542 0.067795785094184449204 0.022940873555798615979 0.040203907210527072003 -0.10305881888996405726 0.050591118228488225761 -0.012160866292998508478 -0.017366472053407251697 0.49262446948924859536 -0.087251590579067311859;-0.024145805746448738976 0.00040910591942320791766 0.063435676529921047884 0.019031050799397691148 0.0086604905241150602346 -0.055812723927518646805 0.059447402986419858872 0.013147773826307300113 -0.0051403153327353222693 0.0058007324916854461141 0.0035134897955918700102 0.047543133887040664454 0.036949092285593246321 0.020385037425181461168 -0.049890262165574836284 -0.022826611561484296681 -0.0117793308434661851 0.0084159802702721015627 0.045654694890596987655 -0.052487164661445012692;-0.19284635798884758318 0.023953771509727193184 0.12302333385902987362 0.025701224833655524765 0.0092923713324289565485 -0.023671191962963984007 -0.099655521066390598262 -0.026267132253318281609 0.051574945100182199853 0.025946542642580960186 -0.020854488404269438256 -0.26462690706731650803 -0.034990112898022861232 0.010501107638600791147 -0.042628189701051477645 0.00304257923516781199 -0.0053454659387617581984 -0.0018421834850615177032 0.13682703519954600435 -0.055737376471361468888;0.096476577609770630684 0.03137121217214611929 -0.23013359380149506217 0.0030300284649437238607 0.0025625029448691945266 0.26494169500660830208 0.15009152733015848624 0.015270027935974525568 0.024455732690270865631 0.024525552952128503587 0.032016035808027941412 0.62613497981316112995 0.10158655985472364591 -0.018510627765228271358 0.15647186765444859313 0.013642482014018309996 -0.0036653993109692670042 -0.0038146815959646906795 0.020284565083950042291 0.49123951549529082383;-6.1567909658072236853e-07 -3.0396949141305439383e-07 -1.3044587567402104024e-07 2.8671974632885391866e-07 6.3182985889021662071e-07 -1.2796160964979396926e-07 -4.3010073442074819362e-07 -2.9800768449378693171e-07 -1.761410294619421644e-07 -9.854368240074049557e-08 4.5861485552149688834e-07 -3.4479703922532636416e-08 2.3514318781218071126e-07 7.0473364180770961212e-08 -1.8631338687799068405e-07 6.0118819352008501423e-07 4.3362510077316316311e-07 -5.8156289146488093657e-07 -5.6367104141064886051e-07 -4.5347706049620189025e-07;0.080036032894200442867 0.016063636483192249294 -0.0018428383364870635445 0.0032505475363719007857 0.01190460643503858662 0.024499495834457471477 -0.0093714412036894900737 -0.016401049524691336395 -0.018334376195832443462 0.019905713355498108608 -0.0017725817061005125479 0.037030712433518631066 0.012211182251807499444 -0.0051378788649590646787 0.049284453012519720272 0.020000964448482570074 -0.012428349113382515176 0.021009061617543400846 0.00021811847722860114741 0.047392977632714113068;-0.073473339141255200602 0.0203068022037760261 0.032379153453323511469 0.00044099361675503634915 -0.016407870472787862426 -0.0070572648598355453703 -0.0096611321090328185907 0.011923938796628241049 0.018340957384659770796 -0.010153688187465995107 0.012110321951213554384 -0.053233486891486027359 0.0012638019594763316624 0.0089445205087575474501 0.03901767918453141748 -0.0043774280551153793226 0.035121073787848476611 0.004798125145781757632 0.072943912217176637425 -0.039084612665055043501;-0.0046704839427934158325 -0.027011539702675668728 -0.039700065364220854525 -0.027358907919895997934 -0.0026782926710473727028 0.010097795050142584217 -0.077449173025366621625 -0.072874118982869953709 -0.17686552064120900085 -0.015851271992030808305 0.0124262270679488529 -0.098023194137702898687 0.011821224079840660093 -0.028214540141599558226 -0.022746105402460199685 -0.024392594278378882527 0.066134539050817744976 -0.00068792097665005462557 0.012650067200509935994 -0.11820376456966849577];
% Layer 3
b3 = -0.1665239426782349208;
LW3_2 = [-0.63244335551487773639 -0.00011181392839542574416 0.033827315169474792 0.068136394960732774018 -0.016783166129040766323 0.42620205782335257583 -5.4306974522404633554e-07 -0.00065773877942655145472 -0.001828895870350139485 -4.9463322654984056403e-07 -6.2551692617768522419e-05 0.61292070690785116494 -0.91711922143534374552 -0.14213569272591969339 -0.39461505674065439075 0.74569159197196810407 -2.4385146757820176701e-07 0.091818406659224485744 -0.11173343929298673594 -0.036661985627214108141];
% Output 1
y1_step1.ymin = -1;
y1_step1.gain = 0.882802087508233;
y1_step1.xoffset = -1.22568411949813;
% ===== SIMULATION ========
% Format Input Arguments
isCellX = iscell(X);
if ~isCellX
X = {X};
end
if (nargin < 2), error('Initial input states Xi argument needed.'); end
% Dimensions
TS = size(X,2); % timesteps
if ~isempty(X)
Q = size(X{1},2); % samples/series
elseif ~isempty(Xi)
Q = size(Xi{1},2);
else
Q = 0;
end
% Input 1 Delay States
Xd1 = cell(1,12);
for ts=1:11
Xd1{ts} = mapminmax_apply(Xi{1,ts},x1_step1);
end
% Input 2 Delay States
Xd2 = cell(1,12);
for ts=1:11
Xd2{ts} = mapminmax_apply(Xi{2,ts},x2_step1);
end
% Allocate Outputs
Y = cell(1,TS);
% Time loop
for ts=1:TS
% Rotating delay state position
xdts = mod(ts+10,12)+1;
% Input 1
Xd1{xdts} = mapminmax_apply(X{1,ts},x1_step1);
% Input 2
Xd2{xdts} = mapminmax_apply(X{2,ts},x2_step1);
% Layer 1
tapdelay1 = cat(1,Xd1{mod(xdts-[0 1 2 3 4 5 6 7 8 9 10 11]-1,12)+1});
tapdelay2 = cat(1,Xd2{mod(xdts-[0 1 2 3 4 5 6 7 8 9 10 11]-1,12)+1});
a1 = poslin_apply(repmat(b1,1,Q) + IW1_1*tapdelay1 + IW1_2*tapdelay2);
% Layer 2
a2 = poslin_apply(repmat(b2,1,Q) + LW2_1*a1);
% Layer 3
a3 = repmat(b3,1,Q) + LW3_2*a2;
% Output 1
Y{1,ts} = mapminmax_reverse(a3,y1_step1);
end
% Final Delay States
finalxts = TS+(1: 11);
xits = finalxts(finalxts<=11);
xts = finalxts(finalxts>11)-11;
Xf = [Xi(:,xits) X(:,xts)];
Af = cell(3,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)
y = bsxfun(@minus,x,settings.xoffset);
y = bsxfun(@times,y,settings.gain);
y = bsxfun(@plus,y,settings.ymin);
end
% Linear Positive Transfer Function
function a = poslin_apply(n,~)
a = max(0,n);
a(isnan(n)) = nan;
end
% Map Minimum and Maximum Output Reverse-Processing Function
function x = mapminmax_reverse(y,settings)
x = bsxfun(@minus,y,settings.ymin);
x = bsxfun(@rdivide,x,settings.gain);
x = bsxfun(@plus,x,settings.xoffset);
end
0 Comments
Accepted Answer
Anshika Chaurasia
on 14 Jun 2021
Edited: Anshika Chaurasia
on 14 Jun 2021
Hi,
Here X is shifted input and Xi is Initial input delay states.
Consider number of delays used is 2. Suppose your input (voltage) is 1x100 and output (angle of arm) is 1x100.
Then X will be 2x98 where 1st row will be elements from input(3:100) and 2nd row will be elements from output(3:100).
The Xi will be 2x2 where 1st row will be elements from input(1:2) and 2nd row will be elements from output(1:2).
The tapped delay lines in the time-series time delay network need to be filled with initial conditions, which requires that part of the original data set be removed and shifted. You can use preparets that uses the network object to determine how to fill the tapped delay lines with initial conditions, and how to shift the data to create the correct inputs and targets to use in training or simulating the network.
Hope it helps!
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!