Cody

# Problem 652. Put two time series onto the same time basis

Solution 1264661

Submitted on 8 Sep 2017 by yurenchu
• Size: 39
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
t1 = [1 2 3 4 5]; d1 = [2 3 5 6 3]; t2 = [2 3.5 4 4.5 5 6]; d2 = [3 9 8 2 0 1]; [tn,d1n,d2n] = align_time_series(t1,d1,t2,d2); tnc = [2 3 3.5 4 4.5 5]; d1nc = [3 5 5.5 6 4.5 3]; d2nc = [3 7 9 8 2 0]; assert(isequal(tn,tnc)) assert(isequal(d1n,d1nc)) assert(isequal(d2n,d2nc))

2   Pass
t1 = [1 3 5]; d1 = [2 4 2]; t2 = [2 4]; d2 = [1 5]; [tn,d1n,d2n] = align_time_series(t1,d1,t2,d2); tnc = [2 3 4]; d1nc = [3 4 3]; d2nc = [1 3 5]; assert(isequal(tn,tnc)) assert(isequal(d1n,d1nc)) assert(isequal(d2n,d2nc))

3   Pass
t1 = 0:2:20; d1 = t1.^2 - 12; t2 = [2 3 5 7 11 13 17 19]; d2 = 4*t2 - 6; [tn,d1n,d2n] = align_time_series(t1,d1,t2,d2); tnc = [2 3 4 5 6 7 8 10 11 12 13 14 16 17 18 19]; d1nc = [-8 -2 4 14 24 38 52 88 110 132 158 184 244 278 312 350]; d2nc = [2 6 10 14 18 22 26 34 38 42 46 50 58 62 66 70]; assert(isequal(tn,tnc)) assert(isequal(d1n,d1nc)) assert(isequal(d2n,d2nc))

4   Pass
t1 = [1 3 5 6 7 8 9]; d1 = [2 4 2 1 1 1 1]; t2 = [2 4]; d2 = [1 5]; [tn,d1n,d2n] = align_time_series(t1,d1,t2,d2); tnc = [2 3 4]; d1nc = [3 4 3]; d2nc = [1 3 5]; assert(isequal(tn,tnc)) assert(isequal(d1n,d1nc)) assert(isequal(d2n,d2nc))
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}