dynamic time warp matlab economic data

I would like to apply the dynamic time warp in economic data of capb i calculated and imf capb. How to code the dynamic time warp in matlab using the two time seriese data.

Answers (1)

Signal processing toolbox, dtw

1 Comment

Good Day
I am trying to apply the DTW, i have tWo economic varaibles name, [tvp_elstcy_CAPB and capb_imf1], years1, it a time series fron 1979 to 2020 it not balanced, can am not able to apply DTW code below what is that am doing wrong i have atteched files as well.
% DTW & CDTW example
% Sinusoidal signals temporal alignment
clear all
clc
close all
load matlab.mat
%fs=125;
%f1=1; A1=1;
%f2=5; A2=0.8;
%years1=0:1/fs:1/(2*f1);
%years1=0:1/fs:2/(2*f2);
%n1=(A1/10)*rand(size(years1));
%n2=(A2/8)*rand(size(years1));
%tvp_elstcy_CAPB=A1*sin(2*pi*f1*years1)+n1; % 1st sinusoid with noise addition
%capb_imf1=A2*sin(2*pi*f2*years1)+n2; % 2nd sinusoid with noise addition
figure; hold on;
plot(years1,tvp_elstcy_CAPB,'b');
plot(years1,capb_imf1,'r');
grid;
xlabel('time (s)');
ylabel('amplitude (mV)');
title('Original disaligned waves');
pflag=1;
%%
[dtw_Dist,D,dtw_k,w,tvp_elstcy_CAPBw,capb_imf1w]=dtw(tvp_elstcy_CAPB,capb_imf1,pflag);
dtw_Dist, dtw_k
[cdtw_Dist,D,cdtw_k,w,tvp_elstcy_CAPBw,capb_imf1w]=cdtw(tvp_elstcy_CAPB,capb_imf1,pflag);
cdtw_Dist, cdtw_k

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!