For/If loop in cell array
Show older comments
Hi,
I have a question regarding implementing a for and if loop with cell arrays.
I have a matrix A{1x24 cell} Each cell contains ages of people, but each cell has a different length (i.e. A{1} is 2362x1, while A{2} is 2344x1, etc.).
Now I want to apply an if loop that for each value in A which is >=1, that specific value will be subtracted by 1.
Can anyone help me with this?
Accepted Answer
More Answers (1)
Walter Roberson
on 14 Sep 2015
Anew = cellfun(@(V) V - (V>=1), A);
Categories
Find more on Loops and Conditional Statements 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!