Cody

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

Solution 196500

Submitted on 25 Jan 2013 by J.R.! Menzinger
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))

Suggested Problems

More from this Author50

Community Treasure Hunt

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

Start Hunting!