How to put Hex numbers inside a matrix?

4 次查看(过去 30 天)
Mike
Mike 2013-7-10
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

回答(1 个)

Jan
Jan 2013-7-10
编辑:Jan 2013-7-10
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 个评论
Mike
Mike 2013-7-10
Thanks Jan, do you have any better idea to put hex numbers inside a matrix?

请先登录,再进行评论。

产品

Community Treasure Hunt

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

Start Hunting!

Translated by