1 X 1 Struct . weird results

  • Follow


I have a 1X1 Struct . I want to perform some arithmetic operation on the element of the struct.  for example when I add 1 to the element , somehow it turns into 7 element matrix. 
Show the output below.

K>> US0003M.LAST_PRICE
ans =
0.4375
K>> US0003M.LAST_PRICE+1
ans =
    49    47    53    52    56    54

Thanks,
0
Reply noel.kennedy (2) 8/9/2012 7:03:15 PM

"Noel " <noel.kennedy@depfa.com> wrote in message <k011hj$f89$1@newscl01ah.mathworks.com>...
> I have a 1X1 Struct . I want to perform some arithmetic operation on the element of the struct.  for example when I add 1 to the element , somehow it turns into 7 element matrix. 
> Show the output below.
> 
> K>> US0003M.LAST_PRICE
> ans =
> 0.4375
> K>> US0003M.LAST_PRICE+1
> ans =
>     49    47    53    52    56    54
> 
> Thanks,

I'm guessing that US0003M.LAST_PRICE is stored as a string. So by adding 1 to each element, you are incrementing the ASCII codes for each character in 0.4375 by 1. Do the following:
char(US0003M.LAST_PRICE+1)
You will get 1/5486, which is the ASCII character representation of 0.4375 incremented by 1.
Barry
0
Reply barry.r.williamsNOSPAM (248) 8/9/2012 7:18:16 PM


1 Replies
16 Views

(page loaded in 0.074 seconds)


Reply: