Sum up a value to a row and create new colum at the end of the cell
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Maria
le 27 Juil 2014
Réponse apportée : Andrei Bobrov
le 27 Juil 2014
How can I add to a row 1 unit? I have the following cell:
A= {12 1996 1999
15 1999 2002
26 1997 2001
43 1999 2008
59 1995 2000}
I would like the output to be:
Output={A= {12 1996 1999 2000
15 1999 2002 2003
26 1997 2001 2004
43 1999 2008 2009
59 1995 2000 2001}
I tried this:
A(:,end+1) = cell2mat(A(:,3))+1;
It gives me the error: 'Conversion to cell from double is not possible.'
But if I take out the 'cell2mat', I get the error: 'Undefined function 'plus' for input arguments of type 'cell'.'
Does someone know how to solve the problem? Thank you
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 27 Juil 2014
Modifié(e) : Azzi Abdelmalek
le 27 Juil 2014
cell2mat(cellfun(@(x) [x x+1],A,'un',0))
%or
[A num2cell([A{:}]+1)']
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!