3D Matrix distance

8 views (last 30 days)
Alex Henderson
Alex Henderson on 28 Aug 2020
Edited: Alan Stevens on 28 Aug 2020
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 Comments
Alex Henderson
Alex Henderson on 28 Aug 2020
Hi Rik! I'll tell you what I'm trying to do here:
I have a 3D grid of excitatory and inhibitory neurons denoted as 1 and -1, respectively
Now I am trying to implement this probality function to get a probability matrix that determines the chance that a neuron will connect with another neuron (keep in mind that one neuron can have connections with many other neurons):
Once I get those probabilities I can use that as a constraint in an overall matrix that represents the connections (for exmaple, 1 if they form a connection 0 they dont form a connection)....
lambda is a control parameter already defined
D(a,b) is the Euclidean distance between neurons a and b
C is a constant whose value depends on the type of neurons that are being connected: 0.3 (EE), 0.2 (EI), 0.4 (IE), 0.1 (II) (still trying to figure out who to implement this as well)
As of now I have the coordinates of all 135 neurons. I believe my next step is getting those 18,225 values representing those distances. I think that's where I'm stuck!!
Alan Stevens
Alan Stevens on 28 Aug 2020
Edited: Alan Stevens on 28 Aug 2020
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.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!