如何确定矩阵中存储的重要行?

时间:2019-06-08 14:49:57

标签: matlab

我没有以下描述的解决方案。如果完整的解决方案要求太多,那么有人能引导我找到解决这个问题的方法/方法,我会非常高兴。另外,如果此问题陈述不适合Matlab,请建议一个适当的论坛来发布此问题。

问题描述

我有一个矩阵M,其行和列索引对应于绘图图中的X轴和Y轴。特定行i和第j列的值对应于图中的点。样本矩阵结果创建如下:

x=1:0.1:50;
lineA=4*x+3;
lineB=x+1;
lineC=0.1*x-10;
lineD=-3*x+15;

range=[0:500];
rangeLength=length(range);

np = numel(lineA);
idCol = 1:np ;
result = zeros(rangeLength,np);

idRowA = 250+1-( round( lineA ) ) ;
linearInd           = sub2ind( [rangeLength,np], idRowA, idCol ) ;
result(linearInd)   = 10 ; %Importance of line A is 10

idRowB = 250+1-( round( lineB ) ) ;
linearInd           = sub2ind( [rangeLength,np], idRowB, idCol ) ;
result(linearInd)   = result(linearInd) + 1 ; % Importance of line B is 1

idRowC = 250+1-( round( lineC ) ) ;
linearInd           = sub2ind( [rangeLength,np], idRowC, idCol ) ;
result(linearInd)   = result(linearInd) + 1 ; %Importance of line C is 1

idRowD = 250+1-( round( lineD ) ) ;
linearInd           = sub2ind( [rangeLength,np], idRowD, idCol ) ;
result(linearInd)   = result(linearInd) +5 ; % importance of line D is 5

我们可以使用下面的代码绘制此矩阵结果,以更好地可视化其数据:

[a,~]=size(result);
[Y, X] = find(result > 0);
plot(X, (a-Y+1), '.');

enter image description here

我们可以从代码中观察到并绘制出A,B,C和D行的值存储在矩阵结果中的信息。请注意,图中所有线的线宽都相同,但线A的重要性比线B的重要性大10个数量级。线A的重要性是线D的两倍。

问题查询

现在,假设我已经从其他函数接收到矩阵结果。我不知道使用了哪些行函数来创建此矩阵。我所知道的是,用于创建此矩阵的线条的重要性不同。我想找出这条线的方程,该方程很可能类似于用于创建此矩阵的最重要的线,然后是第二重要的线,依此类推。

因此,在上面创建的示例矩阵中,解决方案应给我以下一行作为最重要的一行:

mostImpLine=[7 7.4 7.8 8.2 .........203]; %Note that this is same as lineA
secondMostImpLine=[12 11.7 11.4 ....]; %Note that this is same as lineB

我知道在一个大型数据集中,不可能获得与lineA一样的确切结果,但是最接近lineA的近似值就可以完成工作。

0 个答案:

没有答案
相关问题