adding a constant to every term in a cell array
31 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
shobhit mehrotra
il 27 Gen 2015
Commentato: Image Analyst
il 28 Gen 2015
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 Commenti
Risposta accettata
Azzi Abdelmalek
il 27 Gen 2015
Modificato: Azzi Abdelmalek
il 27 Gen 2015
A = {[1 2 3] [4 5 6] [7 8 9]}
out=cellfun(@(x) x+5,A,'un',0)
2 Commenti
Image Analyst
il 28 Gen 2015
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?
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Multidimensional Arrays in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!