3D Matrix distance
이전 댓글 표시
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
Rik
2020년 8월 28일
Your code doesn't seem related to the text you posted. Do you want an array with Euclidean distances? Why would you want to store all of them? You will get 18225 values just for this small array. What is your end goal?
Alex Henderson
2020년 8월 28일
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개)
카테고리
도움말 센터 및 File Exchange에서 Pattern Recognition에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
