How to put Hex numbers inside a matrix?

3 visualizaciones (últimos 30 días)
Mike
Mike el 10 de Jul. de 2013
I'm trying to put some Hex numbers inside a matrix. That's my code:
-----------------------------
>> syms matrix
>> matrix(1,1)='c080'
matrix =
c080
-----------------------------
>> matrix(1,2)='a9faee80'
matrix =
[ c080, a9faee80]
-----------------------------
>> matrix(1,3)='1f00'
Here the Error occurs and i don't know why!
I'll be so thankful for any kind of help!
-----------------------------
Error Message:
Error using sym>convertExpression (line 2246) Conversion to 'sym' returned the MuPAD error: Error: Unexpected 'identifier'. [line 1, col 2]
Error in sym>convertChar (line 2157) s = convertExpression(x);
Error in sym>convertCharWithOption (line 2140) s = convertChar(x);
Error in sym>tomupad (line 1871) S = convertCharWithOption(x,a);
Error in sym (line 104) S.s = tomupad(x,'');
Error in sym/subsasgn (line 1613) if ~isa(B,'sym'), B = sym(B); end

Respuestas (1)

Jan
Jan el 10 de Jul. de 2013
Editada: Jan el 10 de Jul. de 2013
With "syms" the created matrix is symbolic, then it contains symbolic variables. The names of these variables must follow the standard rules of Matlab: less than 64 characters, only letters, numbers and the underscore, but the first character must be a letter. Therefore 'c080' is valid, while '80c0' is not.
What do you want to achieve? Hexadecimal values are stored as strings, so you either need a cell string or perhaps storing the values in the usual decimal format is the most direct solution. But syms seems to be not sufficient for the job.
  1 comentario
Mike
Mike el 10 de Jul. de 2013
Thanks Jan, do you have any better idea to put hex numbers inside a matrix?

Iniciar sesión para comentar.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by