Replace cell elements with a constant value?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Right now, I have a 4x4 cell and in each element of the cell is 25x25 values. I want to be able to go into the first cell element (1,1) and replace every single one of the 25x25 values with a constant (already defined as a variable earlier in my code). This will be within a for loop, and k has been defined as the cell element number (1 through 16 since the cell is 4x4). I am hoping to just be able to say within cell{k} replace every element with constant. And then I want to proceed and be able to replace every single cell element. Therefore, the end will be a 4x4 cell. Within each cell element, there will be 25x25 values that are all the same. Thank you for any help!
Respuestas (1)
Image Analyst
el 30 de Ag. de 2018
Try this (untested)
for k = 1 : numel(ca) % For every cell
% Make array of all one number.
% Then replace existing contents with this array.
ca{k}= yourConstant * ones(size(ca{k}));
end
It uses linear indexing so it should still retain the 2-D shape of the cell array, ca.
2 comentarios
Image Analyst
el 4 de Sept. de 2018
Attach your full code. I don't even use anything called GLCM or call graycomatrix() or graycoprops(), so it's your code, not mine that's giving the error. You did not even mention that you were using the Gray Level Cooccurrence Matrix before now.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!