存储特定索引位置的矩阵向量乘法的迭代 [英] Iteration of matrix-vector multiplication which stores specific index-positions

查看:115
本文介绍了存储特定索引位置的矩阵向量乘法的迭代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要解决最小距离问题,以查看正在尝试的一些工作:

I need to solve a min distance problem, to see some of the work which has being tried take a look at:

链接:点击这里

我有四个元素:两个列向量:昏暗(px1)alpha和昏暗(qx1)beta.在这种情况下,p = q = 50分别给出两个昏暗的(50x1)列向量.它们的定义如下:

I have four elements: two column vectors: alpha of dim (px1) and beta of dim (qx1). In this case p = q = 50 giving two column vectors of dim (50x1) each. They are defined as follows:

alpha = alpha = 0:0.05:2;
beta = beta = 0:0.05:2;

我有两个矩阵:L1L2.

L1由每个尺寸为(kx1)的三个列向量组成.

L1 is composed of three column-vectors of dimension (kx1) each.

L2由每个维度为(mx1)的三个列向量组成.

L2 is composed of three column-vectors of dimension (mx1) each.

在这种情况下,它们的大小相等,这意味着k = m = 1000给出:L1L2分别为昏暗的(1000x3).这些矩阵的值是预定义的.

In this case, they have equal size, meaning that k = m = 1000 giving: L1 and L2 of dim (1000x3) each. The values of these matrices are predefined.

尽管如此,它们仍具有以下结构:

They have, nevertheless, the following structure:

L1(kx3) = [t1(kx1) t2(kx1) t3(kx1)];
L2(mx3) = [t1(mx1) t2(mx1) t3(mx1)];

分钟(数学上)给出了我需要解决的距离问题:

The min. distance problem I need to solve is given (mathematically) as follows:

 d = min( (x-(alpha_p*t1_k - beta_q*t1_m)).^2 + (y-(alpha_p*t2_k - beta_q*t2_m)).^2 +
 (z-(alpha_p*t3_k - beta_q*t3_m)).^2 )

x,y,z是三个固定常数.

我的问题

我需要开发一个迭代,该迭代可以使我从alpha, beta, L1L2组合返回索引位置,从而可以从上方满足最小距离问题.

I need to develop an iteration which can give me back the index positions from the combination of: alpha, beta, L1 and L2 which fulfills the min-distance problem from above.

我希望问题的表述清楚,我对索引符号非常小心.但是,如果仍然不清楚...的步长:

I hope the formulation for the problem is clear, I have been very careful with the index notations. But if it is still not so clear... the step size for:

alpha是p = 1,... 50

alpha is p = 1,...50

beta是q = 1,... 50

beta is q = 1,...50

对于L1; t1, t2, t3是k = 1,...,1000

for L1; t1, t2, t3 is k = 1,...,1000

对于L2; t1, t2, t3是m = 1,...,1000

for L2; t1, t2, t3 is m = 1,...,1000

并且我需要找到index of pindex of qindex of kindex of m,这些都为我提供了最小值.到点x,y,z的距离.

And I need to find the index of p, index of q, index of k and index of m which gives me the min. distance to the point x,y,z.

提前感谢您的帮助!

推荐答案

我不知道您的值,所以我无法检查我的代码.我正在使用循环,因为它是最明显的解决方案.可以肯定的是,来自bsxfun -brigarde(;-D)的人会找到更短/更有效的解决方案.

I don't know your values so i wasn't able to check my code. I am using loops because it is the most obvious solution. Pretty sure that someone from the bsxfun-brigarde ( ;-D ) will find a shorter/more effective solution.

alpha = 0:0.05:2;
beta = 0:0.05:2;

L1(kx3) = [t1(kx1) t2(kx1) t3(kx1)];
L2(mx3) = [t1(mx1) t2(mx1) t3(mx1)];
idx_smallest_d =[1,1,1,1];
smallest_d = min((x-(alpha(1)*t1(1) - beta(1)*t1(1))).^2 + (y-(alpha(1)*t2(1) - beta(1)*t2(1))).^2+...
                    (z-(alpha(1)*t3(1) - beta(1)*t3(1))).^2);

%The min. distance problem I need to solve is given (mathematically) as follows:
for p=1:1:50
    for q=1:1:50
        for k=1:1:1000
            for m=1:1:1000
                d = min((x-(alpha(p)*t1(k) - beta(q)*t1(m))).^2 + (y-(alpha(p)*t2(k) - beta(q)*t2(m))).^2+...
                    (z-(alpha(p)*t3(k) - beta(q)*t3(m))).^2);
                if d < smallest_d
                    smallest_d=d;
                    idx_smallest_d= [p,q,k,m];
                end
            end
        end
    end
end

我正在做的是将最小距离预定义为第一个组合的距离,然后检查每个组合,而该距离小于以前的最短距离.

What I am doing is predefining the smallest distance as the distance of the first combination and then checking for each combination rather the distance is smaller than the previous shortest distance.

这篇关于存储特定索引位置的矩阵向量乘法的迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆