I'm trying to replace the 5th column in each cell in a cell array with the 5th column of each cell from another cell array. I made the following function, which does this but also replaces the values in all other columns with 0. How do I do this without deleting all other values from the other columns. The function is:
function [X]=replace_cells(cell)
X={};
for i=1:length(cell)
X{i}(:,[5])=cell{i}(:,[5]);
end
end
Xhas been initialized as an empty array. You are only copying the 5th column from each cell ofcellintoXso the other values can only be0. I would also highly recommend not usingcellas a variable name.