# MATLAB: Replace the first value in each cell of a cell array with the value from another cell array

## MATLAB: Replace the first value in each cell of a cell array with the value from another cell array

cellcell arraydipMATLABsvdwatermarking

I have a cell array containing the eigenvalues of a set of matrices. I have removed the first value from each of the cells in this array, and placed them in a matrix. These values are then manipulated via a set of thresholds based on a watermark image. I have then reconverted matrix of values to a cell array. I would now like to place the values from these new cells into the corresponding first location of the cells in the old array. Any idea’s on how to do this?
ction Code follows: (The last line there is the trouble)
``function D = fun(D,W)Q = 5;[i,j] = size(D)F = cellfun(@(c) c(1), D); % grab the first value from each celldisp(F); % Debug checkfor a = 1:i % Process the values  for b = 1:j      Z = mod(F(a,b),Q);       if W(a,b) == 0          if Z<(3*Q)/4;              F(a,b) = F(a,b)+Q/4-Z;          else              F(a,b) = F(a,b)+5*Q/4-Z;          end       else           if Z              F(a,b) = F(a,b)-Q/4+Z;          else              F(a,b) = F(a,b)+3*Q/4-Z;          end      end  endenddisp(F); % Debug checkF = num2cell(F); % Make the new cell arraydisp(F); % Debug CheckD{1,1} = cellfun(@(F) F{1,1}, F);    % No clue what to do here``

• ``Dnew = arrayfun(@(x,y)reshape([y,x{:}(2:end)],size(x{:})),D,F,'un',0)``
``Dnew = arrayfun(@(x)reshape([F(x),D{x}(2:end)],size(D{x})),reshape(1:numel(F),size(F)),'un',0)``