Replace all numbers in a cell array that are less than 10 to 10.

I have a cell array that holds mutiple different sized cell arrays inside it. The values are all numbers. I want to replace all numbers that are less than 10 to 10.
Thanks in advance!

 Accepted Answer

cellfun(@(C) cellfun(@(M) max(M,10), C, 'uniform', 0), YourOuterCellArray, 'uniform', 0)

4 Comments

I got this error:
Error using cellfun
Input #2 expected to be a cell array, was double instead.
Error in @(C)cellfun(@(M)max(M,10),C,'uniform',0)
Does that mean that inside the cell array are actually doubles instead?
Also, what are the C and M?
I attached the cell I would like manipulated above if it makes it easier
You had posted that you have a cell array that holds different sizes of cell arrays in it. However, that is not accurate: it holds different sizes of numeric arrays in it.
cellfun(@(THIS_IS_A_DUMMY_VARIABLE_THAT_STANDS_IN_FOR_A_PARTICULAR_ARRAY) max(THIS_IS_A_DUMMY_VARIABLE_THAT_STANDS_IN_FOR_A_PARTICULAR_ARRAY,10), h1c, 'uniform', 0)
Thank you so much! Sorry for the confusion. Still very new with MATLAB. Works great.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!