MATLAB Answers

Array View displays a complex number with ## + 00i - isreal returns 1

2 views (last 30 days)
David on 29 Jan 2015
Edited: David on 29 Jan 2015
I have a quaternion processing script which differences two quaternions and then computes the rotation using 2*asin(sqrt((A(1)*sin(PHI/2))^2 + (A(2)*sin(PHI/2))^2 + (A(3)*sin(PHI/2))^2)), where A is the eigenvector and PHI the rotation. For small angles I have to use this equation versus the Q4 = cos(PHI/2) approach.
Anyway, while debugging I used the array viewer to look at the contents of the array containing the output of the equation (contained in one column) above and I noticed in what seems to be randomly sized blocks of my array output that all of the contents of the rows are displayed as complex numbers with the imaginary component showing "+ 00i". Some of the other values in the row are not computed but are input as integer values, yet they also are displayed as complex numbers with the imaginary component showing "+ 00i". If I test the value using isreal it returns "1" = real.
So it appears that the array viewer is displaying odd results, but my output is all real. Obviously the "+ 00i" implies that there is no imaginary component, but why is it being displayed at all?
Since the results are usable, it's not a critical concern to me, unless the storage of complex numbers is twice the size of reals, which would be as I'm working with a large data set.
If I save subsections of the array to another variable, I may or may not get the same results depending on the rows selected. The results change depending on the rows selected. I've included a portion of my array here.
It appears to be a bug, but maybe it's a feature. I'm using Matlab 7.12.0 (R2011a).

Answers (0)

Community Treasure Hunt

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

Start Hunting!