Ell*_*sky 6 matlab matrix octave
我有一个矩阵D(i,j,k),我想找到i,j,k以尽量减少x:
x = D(i,j,k)
Run Code Online (Sandbox Code Playgroud)
例如:
D = rand(10,10,10);
min(min(min(D))) = 0.5123; %The smallest element in D
Run Code Online (Sandbox Code Playgroud)
我想知道的是D的指数给出0.5123
我怎样才能做到这一点?谢谢,艾略特
对于n维情况,使用从大小为n的单元格数组获得ind2sub的逗号分隔列表的输出:
indices = cell(1,ndims(D)); %// define number of indices (size of cell array)
[minVal linInd] = min(D(:)); %// linear index of minimizer
[indices{:}] = ind2sub(size(D),linInd); %// return indices in cell array
indices = cell2mat(indices); %// convert to nx1 vector containing the indices
Run Code Online (Sandbox Code Playgroud)