Merging Cell Array Elements in One Element

3 visualizaciones (últimos 30 días)
tinkyminky93
tinkyminky93 el 3 de Jun. de 2022
Respondida: VINAYAK LUHA el 3 de Jun. de 2022
Hello,
I have a cell array and its elements are like
1x4 cell array
{'1A'}
{'2B'}
{'3C'}
{'4D'}
I don't want to access them seperately, what I want is merge them like
1x1 cell array
{'1A2B3C4D'}
so that I can convert it to decimal easily. How can I do that? Thank you.

Respuesta aceptada

VINAYAK LUHA
VINAYAK LUHA el 3 de Jun. de 2022
Hi ,
CellArr ={'1A','2B','3C','4D'}
CellArr = 1×4 cell array
{'1A'} {'2B'} {'3C'} {'4D'}
MergedCellArr = [CellArr{:}]
MergedCellArr = '1A2B3C4D'
DecValue = hex2dec(MergedCellArr)
DecValue = 439041101

Más respuestas (1)

Johan
Johan el 3 de Jun. de 2022
test= [{'1A'}
{'2B'}
{'3C'}
{'4D'}]
test = 4×1 cell array
{'1A'} {'2B'} {'3C'} {'4D'}
{cell2mat(test')}
ans = 1×1 cell array
{'1A2B3C4D'}

Categorías

Más información sobre Cell Arrays en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by