Bug in symbolic toolbox?

조회 수: 4 (최근 30일)
Junior
Junior 2011년 8월 18일
Hi all, I am experiencing a strange behavior of the sym function. The result of sym('I') is 'I'. While the result of sym('A+I') is 'A+i' with an unwanted lower case letter of 'I'.
Has anyone experienced such a behavior? Is it a bug? and if so is there any workaround?
Thanks, Junior

채택된 답변

Walter Roberson
Walter Roberson 2011년 8월 18일
In the input regions MuPAD recognizes an uppercase I as the imaginary unit (-1)^(1/2). In the output regions, MuPAD uses a lowercase i to display the imaginary unit
I – imaginary unit sqrt(-1) (see DOM_COMPLEX for details)
Complex numbers can be constructed by typing in the corresponding expression, such as 3+4*I. The keyword for typing the imaginary unit I is I (a capital letter i).
Thus, what you are seeing is not a bug.
I know that in Maple it is possible to change the representation letter, but I do not at the moment see any corresponding mechanism in MuPad. (In Maple, it would be by using interface(imaginaryunit=SYMBOL) )
  댓글 수: 1
Junior
Junior 2011년 8월 19일
Thanks Walter for enlightening me on this matter. The conclusion then is that mupad and standard matlab differ in this respect. For me, the imaginary unit was "i" and not "I".

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2011년 8월 18일
It's seeing I as the sqrt(-1). What is your goal by doing it this way?
why not just
syms A I
A+I
?
The other easiest workaround would just be to use a different letter, J, or II.
sym('A+II')
  댓글 수: 5
Sean de Wolski
Sean de Wolski 2011년 8월 18일
Paulo: sym('A+I')
Walter Roberson
Walter Roberson 2011년 8월 18일
MuPad allows variable names that are not valid MATLAB variable names, so as long as you are processing at the MuPAD level, you could, for example, replace I by _I and strip off the underscore later.
Or.... http://www.mathworks.com/help/toolbox/mupad/datatypes/DOM_IDENT.html#DOM_IDENT
Additionally, an arbitrary string of characters enclosed in ‘backticks’ `` is also an identifier. Examples: `x+y`, `a plus 1`. If the string of characters between the back ticks is a valid identifier already, this input form creates the same identifier as the one without the backticks.
Thus, you could substitute (say) `I ` (with a space) where you have the variable I in your input, and the only visible difference with normal typesetting turned on would be an extra space after the I .

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by