Cody

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

Solution 1601161

Submitted on 5 Aug 2018 by Kodavati Mahendra
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))

timeseries Common Properties: Name: 'unnamed' Time: [6x1 double] TimeInfo: [1x1 tsdata.timemetadata] Data: [1x1x6 double] DataInfo: [1x1 tsdata.datametadata] More properties, Methods timeseries Common Properties: Name: 'unnamed' Time: [6x1 double] TimeInfo: [1x1 tsdata.timemetadata] Data: [1x1x6 double] DataInfo: [1x1 tsdata.datametadata] More properties, Methods tn = 2.0000 3.0000 3.5000 4.0000 4.5000 5.0000 d1n = 3.0000 5.0000 5.5000 6.0000 4.5000 3.0000 d2n = 3 7 9 8 2 0

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))

timeseries Common Properties: Name: 'unnamed' Time: [3x1 double] TimeInfo: [1x1 tsdata.timemetadata] Data: [1x1x3 double] DataInfo: [1x1 tsdata.datametadata] More properties, Methods timeseries Common Properties: Name: 'unnamed' Time: [3x1 double] TimeInfo: [1x1 tsdata.timemetadata] Data: [1x1x3 double] DataInfo: [1x1 tsdata.datametadata] More properties, Methods tn = 2 3 4 d1n = 3 4 3 d2n = 1 3 5

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))

timeseries Common Properties: Name: 'unnamed' Time: [16x1 double] TimeInfo: [1x1 tsdata.timemetadata] Data: [1x1x16 double] DataInfo: [1x1 tsdata.datametadata] More properties, Methods timeseries Common Properties: Name: 'unnamed' Time: [16x1 double] TimeInfo: [1x1 tsdata.timemetadata] Data: [1x1x16 double] DataInfo: [1x1 tsdata.datametadata] More properties, Methods tn = 2 3 4 5 6 7 8 10 11 12 13 14 16 17 18 19 d1n = -8 -2 4 14 24 38 52 88 110 132 158 184 244 278 312 350 d2n = 2 6 10 14 18 22 26 34 38 42 46 50 58 62 66 70

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))

timeseries Common Properties: Name: 'unnamed' Time: [3x1 double] TimeInfo: [1x1 tsdata.timemetadata] Data: [1x1x3 double] DataInfo: [1x1 tsdata.datametadata] More properties, Methods timeseries Common Properties: Name: 'unnamed' Time: [3x1 double] TimeInfo: [1x1 tsdata.timemetadata] Data: [1x1x3 double] DataInfo: [1x1 tsdata.datametadata] More properties, Methods tn = 2 3 4 d1n = 3 4 3 d2n = 1 3 5

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!