Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Big mystery: why my uitable display complex numbers when the number in the structure are real?!!!!

Subject: Big mystery: why my uitable display complex numbers when the number in the structure are real?!!!!

From: Camille Couzi

Date: 20 Dec, 2011 03:27:10

Message: 1 of 2

Hello!
Uitable is driving me crazy, I can;t understand that's happening.
I am working on a GUI, and at some stage I display in a uitable data I have stored previously in a structure. This data come from calculations on energy data, which are real numbers (not complex).
My uitable displays my numbers as if they were complex numbers!
For example, if I am displaying the following matrix:
A=[NaN 2; 8 3];

I see in my uitable:
NaN+0.0000i 2+0.0000i
8+0.0000i 3+0.0000i

(Even the NaN appear like NaN+0.0000i that's crazy!!!!)

That's incredible!!! When I load my structure in the command window to be really sure the numbers inside are real, they are in fact real! and if before displaying the data into the uitable I specify:
A2=real(A)
and I display A2, I still can see the fake imaginary part of my numbers!!!

did something similar to this happen to somebody before?!!!!
Thanks in advance for your help!

Camille.

Subject: Big mystery: why my uitable display complex numbers when the

From: Rune Allnor

Date: 20 Dec, 2011 05:32:42

Message: 2 of 2

On 20 Des, 04:27, "Camille Couzi" <c...@dhi.com.sg> wrote:
> Hello!
> Uitable is driving me crazy, I can;t understand that's happening.
> I am working on a GUI, and at some stage I display in a uitable data I have stored previously in a structure. This data come from calculations on energy data, which are real numbers (not complex).

The *formal* algebra might be real-only, but
numeric inaccuracies might cause non-zero
imaginary values.

> My uitable displays my numbers as if they were complex numbers!
> For example, if I am displaying the following matrix:
> A=[NaN  2; 8 3];

Displaying a matrix known tho contain NaNs is
usually and indication that there is a problem
with the computations. Some divide-by-0 type
computations?

> I see in my uitable:
> NaN+0.0000i   2+0.0000i
> 8+0.0000i  3+0.0000i
>
> (Even the NaN appear like NaN+0.0000i that's crazy!!!!)

R2006a:

>> nan+sqrt(-1)

ans =

      NaN + 1.0000i

Well, displaying data in this way might not make
much *formal* sense, but it is certainly helpful
during debugging. It shows that whatever reason
for the NaN result is associated with the real
value. Which might be helpful to isolate the
root of the computational problem.

Rune

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us