MATLAB: If the cell duplicated put last column in the previous row

matching datasave duplicated

i run this code but it gives an error:
j=1;
rowsize=length(defs);
data1=cell([rowsize,C2]); % create array with size [R,C]
for j=1:length(defs) % loop over Mdr of defib
querymdr=data2{j,1}; % save MDR numbers
y=alldata{:,1};
idx= find(y==querymdr); % find in alldata MDR equals def
record=[alldata{idx(1),:}]; % copy the 1st search result
for k=2:length(idx)% over all MDR number of text
record = [record,(alldata(idx(k),6))];
end
data1(j,:)=record; % put combined record into result table
end
what is the wrong thing ?

Best Answer

Maybe idx is empty (i.e., the find didn't result in a match). Do this to verify:
dbstop if error
Then run your code. When the error occurs, the execution will pause and you can examine variable sizes to confirm the problem and why it occurred.