目录
【若觉文章质量良好且有用,请别忘了点赞收藏加关注,这将是我继续分享的动力,万分感谢!】
其他:
1. 时间序列转二维图像方法及其应用研究综述_vm-1215的博客-CSDN博客
2.将时间序列转成图像——格拉姆角场方法 Matlab实现_vm-1215的博客-CSDN博客
3.将时间序列转成图像——递归图方法 Matlab实现_vm-1215的博客-CSDN博客
4.将时间序列转成图像——图形差分场方法 Matlab实现_vm-1215的博客-CSDN博客
5.将时间序列转成图像——相对位置矩阵方法 Matlab实现_vm-1215的博客-CSDN博客
马尔可夫转移场(Markov Transition Field, MTF)是基于马尔可夫转移矩阵的一种时间序列图像编码方法。该方法将时间序列的时间推移看成是一个马尔可夫过程,即:在已知目前状态的条件下,它未来的演变不依赖于它以往的演变,由此构造马尔可夫转移矩阵,进而拓展为马尔可夫转移场,实现图像编码。
对于时间序列X=(xt,t=1,2,...,T)
W=[ω11…ω1Qω21⋯ω2Q⋮⋱⋮ωQ1⋯ωQQ] s.t. ∑jωij=1
M=[ωij∣x1∈qi,x1ϵqj…ωij∣x1∈qi,xN∈qjωij∣x2∈qi,x1ϵqj⋯ωij∣x2∈qi,xN∈qj⋮⋱⋮ωij∣xNϵqi,x1ϵqj⋯ωij∣xN∈qi,xN∈qj]
- clc
- clear
- close all
-
-
- %% 生成数据
- % speed = xlsread('3_1_link6_28_5_30min.csv');
- speed = xlsread('3_1_link1_1_5_30min.csv');
-
- X = speed;
- m = length(X);
-
- %数据初始化[0,1]
- X = (X - min(X))/(max(X) - min(X));
-
- %% 构造转移矩阵W
- N = length(X);
-
- % 分出Q个分位箱(按照个数),从小往大:1、2、3、4
- Q = 4;
-
- % X_Q把每个元素标记为分为箱1、2、3、4,
- X_Q = ones(1,N);
- j = 0;
-
- % 初始化k
- k = ones(1,Q+1);
- for i = 2 : Q+1
-
- % 循环计算小于j的数据个数,达到阈值时跳出循环
- while( sum(X < j) < N * (i-1) / Q)
- j = j + 0.0001;
- end
-
- % 记录每一个分位箱的阈值
- k(i) = j;
-
- % 将原先的数据向量变成对应的分位箱次序向量
- X_Q(find(X < k(i) & X > k(i-1))) = i-1;
- end
-
- %% 计算马尔可夫矩阵
- sum_14 = 0;
- sum_13 = 0;
- sum_24 = 0;
- sum_12 = 0;
- sum_23 = 0;
- sum_34 = 0;
- sum_11 = 0;
- sum_22 = 0;
- sum_33 = 0;
- sum_44 = 0;
- sum_21 = 0;
- sum_32 = 0;
- sum_43 = 0;
- sum_31 = 0;
- sum_42 = 0;
- sum_41 = 0;
-
- for i = 1:N-1
- switch(X_Q(i) - X_Q(i+1))
- case -3
- sum_14 = sum_14 + 1;
- case -2
- switch(X_Q(i))
- case 1
- sum_13 = sum_13 + 1;
- case 2
- sum_24 = sum_24 +1;
- end
- case -1
- switch(X_Q(i))
- case 1
- sum_12 = sum_12 + 1;
- case 2
- sum_23 = sum_23 + 1;
- case 3
- sum_34 = sum_34 + 1;
- end
- case 0
- switch(X_Q(i))
- case 1
- sum_11 = sum_11 + 1;
- case 2
- sum_22 = sum_22 + 1;
- case 3
- sum_33 = sum_33 + 1;
- case 4
- sum_44 = sum_44 + 1;
- end
- case 1
- switch(X_Q(i))
- case 2
- sum_21 = sum_21 + 1;
- case 3
- sum_32 = sum_32 + 1;
- case 4
- sum_43 = sum_43 + 1;
- end
- case 2
- switch(X_Q(i))
- case 3
- sum_31 = sum_31 + 1;
- case 4
- sum_42 = sum_42 + 1;
- end
- case 3
- sum_41 = sum_41 + 1;
- end
- end
-
- W = [sum_11 sum_12 sum_13 sum_14;
- sum_21 sum_22 sum_23 sum_24;
- sum_31 sum_32 sum_33 sum_34;
- sum_41 sum_42 sum_43 sum_44];
- W = W./repmat(sum(W),[4,1])
-
- M = zeros(N,N);
- for i = 1: N
- for j = 1:N
- M(i,j) = W(X_Q(i),X_Q(j));
- end
- end
-
- figure(1)
- plot(X)
- hold on
- for i = 2 : Q
- plot(1:N,ones(1,N)*k(i),'linewidth',1.5);
- hold on;
- end
- im = figure(2);
- imagesc(M)
- saveas(im,'MTF_1.bmp');
- saveas(figure(1),'MTF_01.bmp');
【若觉文章质量良好且有用,请别忘了点赞收藏加关注,这将是我继续分享的动力,万分感谢!】