学习笔记第九篇之用matlab预测数值

    同样是数据预测的问题,数据分为四块,数据格式如下,已知均值0.30478,我需要预测其他八个数据,同时我们也知道当第一个属性为0.6时数据值的情况,其在均值0.3189上下波动,因此我们需要根据这组已知的数据来求出在均值0.30478上下波动的数值。

matlab代码如下

%读取数据,共四块数据,用四个矩阵来存储,每个矩阵是8x8的,每一列第4个为平均值,其余为预测值。根据一致的第五列为已知值。

a = xlsread('walking_pro_topic_num.xlsx');     

A = reshape(a(1:64,3),8,8);

B = reshape(a(1:64,8),8,8);
C = reshape(a(1:64,13),8,8);
D = reshape(a(1:64,18),8,8);
error_matrix_A =  A(:,5) - ones(8,1)*A(4,5);
error_matrix_B =  B(:,5) - ones(8,1)*B(4,5);
error_matrix_C =  C(:,5) - ones(8,1)*C(4,5);
error_matrix_D =  D(:,5) - ones(8,1)*D(4,5) ;
for i=1:8
    if i ~= 5
        A_coloum_i = ones(8,1)*A(4,i) + error_matrix_A;
        A(:,i) = A_coloum_i;
    end
end
for j=1:8
    if j ~= 5
        B_coloum_j = ones(8,1)*B(4,j) + error_matrix_B;
        B(:,j) = B_coloum_j;
    end
end
for k=1:8
    if k ~= 5
        C_coloum_k = ones(8,1)*C(4,k) + error_matrix_C;
        C(:,k) = C_coloum_k;
    end
end
for l=1:8
    if l ~= 5
        D_coloum_l = ones(8,1)*D(4,l) + error_matrix_D;
        D(:,l) = D_coloum_l;
    end
end
A1 = roundn(A, -5);
B1 = roundn(B, -5);
C1 = roundn(C, -5);
D1 = roundn(D, -5);

结果如下所示:


猜你喜欢

转载自blog.csdn.net/zhangye_2017/article/details/79052341