## Multiple Sequences with Dynamic Neural Networks

There are times when time-series data is not available in one long sequence, but rather as several shorter sequences. When dealing with static networks and concurrent batches of static data, you can simply append data sets together to form one large concurrent batch. However, you would not generally want to append time sequences together, since that would cause a discontinuity in the sequence. For these cases, you can create a concurrent set of sequences, as described in Understanding Shallow Network Data Structures.

When training a network with a concurrent set of sequences, it is required that each sequence be of the same length. If this is not the case, then the shorter sequence inputs and targets should be padded with NaNs, in order to make all sequences the same length. The targets that are assigned values of NaN will be ignored during the calculation of network performance.

The following code illustrates the use of the function `catsamples` to combine several sequences together to form a concurrent set of sequences, while at the same time padding the shorter sequences.

```load magmulseq y_mul = catsamples(y1,y2,y3,'pad'); u_mul = catsamples(u1,u2,u3,'pad'); d1 = [1:2]; d2 = [1:2]; narx_net = narxnet(d1,d2,10); narx_net.divideFcn = ''; narx_net.trainParam.min_grad = 1e-10; [p,Pi,Ai,t] = preparets(narx_net,u_mul,{},y_mul); narx_net = train(narx_net,p,t,Pi); ```
{"ft_lang_label":"__label__en","ft_lang_prob":0.8741385,"math_prob":0.9861408,"size":1378,"snap":"2021-31-2021-39","text_gpt3_token_len":324,"char_repetition_ratio":0.13609898,"word_repetition_ratio":0.014778325,"special_character_ratio":0.2322206,"punctuation_ratio":0.17818181,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9638159,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-16T14:54:06Z\",\"WARC-Record-ID\":\"<urn:uuid:aff93f08-15b3-489c-8840-f415e976589d>\",\"Content-Length\":\"66917\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:08c27636-f097-470e-92aa-72ebd43d7c52>\",\"WARC-Concurrent-To\":\"<urn:uuid:830ae7ea-eae4-4767-a1e7-6e36ec1d0def>\",\"WARC-IP-Address\":\"23.197.108.134\",\"WARC-Target-URI\":\"https://la.mathworks.com/help/deeplearning/ug/multiple-sequences-with-dynamic-neural-networks.html\",\"WARC-Payload-Digest\":\"sha1:CKL2GUA4Z65GZJSCSMDPXIQM57H4OOEZ\",\"WARC-Block-Digest\":\"sha1:PFOHXN452T4WUWYYSR6BHFMCV5L3O3LT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780053657.29_warc_CC-MAIN-20210916145123-20210916175123-00430.warc.gz\"}"}