Replace the first value in each cell of a cell array with the value from another cell array
Afficher commentaires plus anciens
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 cell
disp(F); % Debug check
for 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<Q/4;
F(a,b) = F(a,b)-Q/4+Z;
else
F(a,b) = F(a,b)+3*Q/4-Z;
end
end
end
end
disp(F); % Debug check
F = num2cell(F); % Make the new cell array
disp(F); % Debug Check
D{1,1} = cellfun(@(F) F{1,1}, F); % No clue what to do here
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!