[68 65 6c 6c 6f 20 68 6f] i want to convert this vector into a matrix 4*4 with nibble (4 bits)?

2 visualizzazioni (ultimi 30 giorni)
[68 65 6c 6c 6f 20 68 6f]====>[6 8 6 5 ;6 c 6 c ;6 f 2 0 ;6 8 6 f] kindly help
  5 Commenti
Guillaume
Guillaume il 21 Ott 2017
Can you use valid syntax for showing your input. It is not possible to have the literal vector [68 65 6c 6c 6f 20 68 6f] in matlab.
Please show a valid input example and corresponding desired output.
Muhammad Tanveer
Muhammad Tanveer il 21 Ott 2017
Modificato: Guillaume il 21 Ott 2017
clc
format hex
str=input('Enter the key of sixteen alphabets in uper or lowercase case leteers==');
decString = unicode2native(str,'utf-8')
decString =
68 65 6c 6c 6f 20 68 6f 77 20 61 72 65 20 79 6f

Accedi per commentare.

Risposta accettata

Rik
Rik il 24 Ott 2017
All you changed with format hex is the way Matlab shows you the values, you didn't actually change the values. You can convert the decimal values to a hex string, and then concatenate the strings. What you end up with is a 1x32 char vector, which you could reshape into a matrix if you like.
decString=[104,101,108,108,111,32,104,111,119,32,97,114,101,32,121,111];
str=dec2hex(decString(:))';str=str(:)';

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by