a =
[2] [3] [4] [5] [6]
a is of type cell want output of type cell like
out= [23456]
please send me general code for any order of a...and/or if the number consist of sentence.
thanks in advance.

 Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 19 Juil 2014

0 votes

a ={ [2] [3] [4] [5] [6]}
b=str2double(strjoin(cellfun(@num2str,a,'un',0),''))

10 commentaires

azizullah khan
azizullah khan le 19 Juil 2014
??? Undefined function or method 'strjoin' for input arguments of type 'cell'.
matlab gives an error...........thanks for reply
Azzi Abdelmalek
Azzi Abdelmalek le 19 Juil 2014
Try this
a ={ [2] [3] [4] [5] [6]}
b=cellfun(@num2str,a,'un',0)
b=str2num([b{:}])
azizullah khan
azizullah khan le 19 Juil 2014
i want b to be of type cell ... here in your output b is of type double.
Azzi Abdelmalek
Azzi Abdelmalek le 19 Juil 2014
just convert it to cell
b=num2cell(b)
azizullah khan
azizullah khan le 19 Juil 2014
sir, i doesn't work for alphabets..like a =
'a' 'b' 'c'
want b=[abc] or b=['a''b''c']
Azzi Abdelmalek
Azzi Abdelmalek le 19 Juil 2014
Your question is not clear, what type of cell array do you have? cell of numbers or strings or both?
Azzi Abdelmalek
Azzi Abdelmalek le 19 Juil 2014
If your cell looks like
v={'a' 'b' 'c'}
out=[v{:}]
azizullah khan
azizullah khan le 19 Juil 2014
cell which contain both string and number. i want to unite it into one entry. a= 'max' 'ali' '23' output want b=maxali23
Azzi Abdelmalek
Azzi Abdelmalek le 19 Juil 2014
'23' is not a number, it's a string.
v={'a' '23' 'c'}
out=[v{:}]
azizullah khan
azizullah khan le 19 Juil 2014
Thanks... conversion from char to string is required?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by