3D Matrix distance
7 ビュー (過去 30 日間)
古いコメントを表示
I have a 15x3x3 matrix and I want to calculate the euclidean distance between one point and all other points in the matrix and store those values. I want to do this for every single element in my matrix. Logic:
element 1 of 135: calculate distance between element 1 and 2, 1 and 3, 1 and 4...., 1 and 135 -> then story distances in array
element 2 of 135: calculate distance between element 2 and 1, 2 and 2, 2 and 3, 2 and 4, ..... 2 and 135 -> then store distances in arry
element 3 of 135 .... " "
element 4of 135..... " "
you get the picture
This is what I have so far:
EtoIratio = 0.8;
gridspace = zeros(15,3,3);
nSelect = round(numel(gridspace)*EtoIratio);
idx = randperm(numel(gridspace),nSelect);
gridspace(idx) = 1;
neurontype = [];
[row, col, page] = size(gridspace);
for i = 1:row
for j = 1:col
for k = 1:page
if gridspace(i,j,k) == 1
neurontype(i,j,k) = 1;
else neurontype(i,j,k) = -1;
end
end
end
end
ind = find(neurontype);
[r c p] = ind2sub(size(neurontype),ind);
That is what I have so far... anyone have any idea on how to accomplish this?
Thanks!!!
3 件のコメント
Alan Stevens
2020 年 8 月 28 日
編集済み: Alan Stevens
2020 年 8 月 28 日
If lambda is of the order of, or smaller than, your grid spacing then the probability will fall off extremely quickly with distance. I suggest you first do the calculation using nearest neighbour distances, then extend that to next nearest neighbours if that isn't sufficient.
First, perhaps, find what distance (i.e. what value of D) makes the probability insignificant for your problem.
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
