Replace cell elements with a constant value?
Show older comments
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!
1 Comment
madhan ravi
on 30 Aug 2018
Provide your code??
Answers (1)
Image Analyst
on 30 Aug 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 Comments
RB
on 4 Sep 2018
Image Analyst
on 4 Sep 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.
Categories
Find more on Texture Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!