3D array - Assignment has more non-singleton rhs dimensions than non-singleton subscripts

Hi there,
I'm fairly new to Matlab, and to process my data I've begun with writing a simple script. I have a bunch of cells in a video, and I want to know the distance between one cell and all other cells in each frame, and then repeat for all cells - so I would end up with a 3D array with cellnumber vs. cellnumber vs. frame, containing distances.
My script worked well for a practise dataset I made with only 2 cells and 7 frames, but my actual data has 170 frames and 54 cells...
Below is my script: (note that findInd2 and findDist2 are my own functions)
cellNum = mydata(:,2);
frames = mydata(:,3);
xs = mydata(:,4);
ys = mydata(:,5);
dist = zeros(cellNum,cellNum,frames);
numberOfFrames = 170;
for i = 1:numberOfFrames
[ xPos, yPos, xyPos ] = findInd2( frames, xs, ys, i );
[cellDist] = findDist2(xyPos, i);
dist (:,:,i) = cellDist;
end
It works up until the final line
dist (:,:,i) = cellDist;
where I get the error 'Assignment has more non-singleton rhs dimensions than non-singleton subscripts'. I'm not sure what this means - I think I should define the other variables in the 'dist' array but I'm not sure how... Or should it be a 4D array instead?
Any help is much appreciated!
Thanks,
Michelle

Answers (1)

Look at the size of cellDist, it is probably not a cellNum x cellNum array.

This question is closed.

Tags

Asked:

on 5 Apr 2013

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!