I have a set of time series sampled at one second intervals. For example,

  ts1 = TimeSeries[Table[k,{k,0,10}],{0,10}],
  ts2 = TimeSeries[Table[k^2/10,{k,0,10}],{15,25}]

The series do not overlap and are separated by gaps of many seconds.

How to join them to form a single time series such that any attempt to sample that series in a gap between the initial series results in a Missing value?

  • 1
    $\begingroup$ What have your tried? The community expects the following from you: ✅: A clear description of an on-topic problem or goal. ❌: A minimal working Wolfram Language code example, formatted, easy to copy&paste, in Raw InputForm. ❌. An example of what you expect as output. ❌. Some proof of minimal Mathematica knowledge. ❌. Minimum due diligence: Share how you have searched the site and documentation, your attempts and reasons to believe an answer exists. $\endgroup$
    – rhermans
    Commented Dec 15, 2022 at 11:29

1 Answer 1


You can join the two TimeSeries using TimeSeriesInsert. Now to fill the gap with Missing, I recommend using TimeSeriesResample with the ResamplingMethod option set to None

tsj = TimeSeriesResample[
   TimeSeriesInsert[ ts1, ts2 ]
   , ResamplingMethod -> None



(* {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, Missing[], Missing[], Missing[], Missing[], 0, 1/10, 2/5, 9/10, 8/5, 5/2, 18/5, 49/10, 32/5, 81/10, 10} *)

You can choose other methods too

         TimeSeriesInsert[ ts1, ts2 ]
         , ResamplingMethod -> {"Constant",5}
   , Joined -> True
   , PlotTheme -> "Scientific"

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.