adding a constant to every term in a cell array
13 次查看(过去 30 天)
显示 更早的评论
I'm trying to add a constant to every term in the cell array. For example A = {[1 2 3] [4 5 6] [7 8 9]} and I want to add 5 to each term to create a cell array B= { [6 7 8] [ 9 10 11] [ 12 13 14]} Thanks!
0 个评论
采纳的回答
Azzi Abdelmalek
2015-1-27
编辑:Azzi Abdelmalek
2015-1-27
A = {[1 2 3] [4 5 6] [7 8 9]}
out=cellfun(@(x) x+5,A,'un',0)
2 个评论
Image Analyst
2015-1-28
But the question I have is why are you wanting to deal with the hassle of a cell array when you don't have to. You aren't mixing data types. You don't have rows or columns with different sizes. So why aren't you simply using a simple, regular numerical array??? Why make things complicated for yourself?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!