Why do complex matrices display real elements as "1.23e45 + i" when format is set to eng?
Show older comments
There's probably a reasonable reason for this behavior, but I can't seem to understand why this;
format short eng
foo = [2 + 1*i, 3]
prints
foo =
2.0000e+000 + 1.0000e+000i 3.0000e+000 + i
IE. why 0.0000e+000 isn't printed before the second 'i' character. As it is now the (IMHO) reasonable assumption is that foo(2) is in fact 3+1*i, rather than 3+0*i.
This behavior is not present with the default format mode, where the output is instead an, arguably more reasonable,
foo =
2.0000 + 1.0000i 3.0000 + 0.0000i
Thanks!
3 Comments
Stephen23
on 26 Jul 2016
MATLAB 2012b:
>> format short
>> foo = [2 + 1*i, 3]
foo =
2.0000 + 1.0000i 3.0000
>> format short eng
>> foo
foo =
2.0000e+000 + 1.0000e+000i 3.0000e+000
Jonathan Lock
on 26 Jul 2016
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!