Using j for imaginary numbers

I tend to use i for imaginary numbers and not j. In confirming that MATLAB is happy to use either I typed
j
and got
ans = 0 + 1.0000i
so if I wanted to go back to my electrical engineering roots and use j, can I make MATLAB say
j
ans = 0 + 1.0000j
and
i
ans = 0 + 1.0000j

 Réponse acceptée

Jan
Jan le 13 Mai 2012

2 votes

You can overload @double\display with your personal display routine. Or use:
c = 1+1j*2;
Str = evalc('display(c)');
disp(strrep(Str, 'i', 'j'));

2 commentaires

Daniel Shub
Daniel Shub le 13 Mai 2012
While it is a mighty big hammer, it does answer the question.
Jan
Jan le 13 Mai 2012
display(inf) replies "Inf", such that the brute replacing i->j does not bother.

Connectez-vous pour commenter.

Plus de réponses (1)

Wayne King
Wayne King le 11 Mai 2012

2 votes

I know this isn't a real answer, but it seemed a bit long for a comment. I'm guessing all you can do is display the result in that format
c = 1+1j*2;
sprintf('%d+%dj\n',real(c),imag(c))

1 commentaire

Daniel Shub
Daniel Shub le 13 Mai 2012
I think I was curious if there was a preference someplace that could be set.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by