What is best option to separate bytes from hex vector (char vector)?
Mostrar comentarios más antiguos
Hi, I have a HEX vector:
A = 'ABCDEF12';
and I want to seprate them to array or cell by bytes:
{"AB"},{"CD"},{"EF"},{"12"}
I know that this is easy, but i have no idea. Best option would be loop here
3 comentarios
KALYAN ACHARJYA
el 22 de Oct. de 2019
James Tursa
el 22 de Oct. de 2019
Do you want the split results to remain as char or string, or will they be converted to numeric values for downstream use?
Guillaume
el 22 de Oct. de 2019
Comment by Phill Lord probably as an answer to kalyan's comment originally posted as an answer moved here:
Thanks, I have checked, but this not helped me :( In that solution, we have a known character to split - I need split every double chars.
Respuestas (1)
Assuming that the number of characters is even:
split = mat2cell(A, 1, repelem(2, numel(A)/2))
Note that this will produce a cell array of char vectors. You show your desired output as a cell array of scalar strings ("" notation instead of '' notation). It wouldn't make sense to generate a cell array of strings, you'd either have a cell array of char vectors as the above or a plain string array, which you'd obtain from the above with:
s_split = string(split);
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!