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
0 个评论
回答(1 个)
Look at the size of cellDist, it is probably not a cellNum x cellNum array.
0 个评论
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!