找到最小值(x1,x2,x1 x1 * x2 * x3,…,x1 * x2 *…* xN)在Matlab

时间:2021-06-08 22:08:17

xi=exprnd(1,M,1), i=1,...,N, is a column vector of M x 1 size. This means that the j-th element of xi is xi(j)>=0.

ξ= exprnd(1米1),我= 1,……,N,是mx1大小的列向量。这意味着xi的第j个元素是xi(j)>=0。

I want to get the column vector X of Mx1 size where the j-th element of X is X(j)=min[x1(j), x1(j)*x2(j), x1(j)*x2(j)*x3(j), ..., x1(j)*x2(j)*...*xN(j)].

我想要得到列向量X(Mx1)的大小其中第j个元素X(j)=min[x1(j), x1(j)*x2(j), x1(j)*x2(j)* x2(j)*x3(j),…x1,x2(j)*(j)*…* xN(j)]。

Can anyone help me with MATLAB code which works for any M and N?

谁能帮我写一个适用于任意M和N的MATLAB代码吗?

1 个解决方案

#1


5  

Build your vectors directly as columns of an MxN matrix:

直接将向量构建为MxN矩阵的列:

xi = exprnd(1,M,N);

Then the desired result can be obtained computing the cumulative product along the second dimension (cumprod) and then minimizing along the second dimension (min):

然后,可以得到期望的结果,在第二个维度(cumprod)上计算累积乘积,然后沿着第二个维度(min)最小化:

result = min(cumprod(xi,2),[],2);

#1


5  

Build your vectors directly as columns of an MxN matrix:

直接将向量构建为MxN矩阵的列:

xi = exprnd(1,M,N);

Then the desired result can be obtained computing the cumulative product along the second dimension (cumprod) and then minimizing along the second dimension (min):

然后,可以得到期望的结果,在第二个维度(cumprod)上计算累积乘积,然后沿着第二个维度(min)最小化:

result = min(cumprod(xi,2),[],2);