Reputation: 777
I am writing some Matlab code to analyze spikes and their stimuli. In the first part of the code I get the timing of a spike and then find the frame that was shown on the screen just prior. I then want to take the image data from that frame and add it to my own movie data. The x and y components of myMovie
and moviedata
are both 128x128, however when I try to add the image values from a certain frame from the stimuli moviedata(:,:,j)
to a specific frame in my movie myMovie(:,:,k)
I get "error: matrix dimensions must agree". Is there any way to fix this?
Code:
for n=1:1100
t = blocks(5).spikes{1}(:,n);
for k=1:25
ind = find(round(double(blocks(5).frameEpocs*1000)/1000) == (t-(1/(25*10))));
j = blocks(5).frameEpocs(1,ind);
myMovie(:,:,k) = myMovie(:,:,k) + double(moviedata(:,:,j));
end
end
Upvotes: 0
Views: 61
Reputation: 2342
find
may return an empty matrix and hence j
would be empty as well.
In that case, the command myMovie(:,:,k) + double(moviedata(:,:,j));
attempts to add a 128x128x1 matrix with a 128x128x0 matrix and thus the error you got.
Upvotes: 2