Hello Does anyone have a hint on how to convert a set of 12-bites unsigned interger to float, using matlab? Matlab shows the following syntax using float a = float('single') a = float('double') a = float(TotalBits, ExpBits) // here is an example of 12-bit unsigned int x=[ 2843 2845 2851 2869 2838 2840 2853 2864]; I have tried these 3 float syntaxes , but i don't get any conversion? Any ideas on how to use them?? Thanks in advance!
Converting 12-bits unsigned integer to floats using matlab
Started by ●April 10, 2006
Reply by ●April 10, 20062006-04-10
"Umutesi Faith" <ma_nz1@yahoo.com> wrote in message news:xYKdneCeBJAyjafZRVn-gQ@giganews.com...> > Hello > > Does anyone have a hint on how to convert a set of 12-bites unsigned > interger to float, using matlab? > Matlab shows the following syntax using float > > a = float('single') > a = float('double') > a = float(TotalBits, ExpBits) > > // here is an example of 12-bit unsigned int > x=[ > 2843 > 2845 > 2851 > 2869 > 2838 > 2840 > 2853 > 2864]; > > I have tried these 3 float syntaxes , but i don't get any conversion? > Any ideas on how to use them?? > Thanks in advance! >have you tried looking at the help for fread? using bit12 or ubit12 as a format? Best of luck - Mike
Reply by ●April 10, 20062006-04-10
hi, it seems that 12-bits are not supported in these format. however even if i convert these to 16-bits, there is still no result of the conversion! Does anyone have an idea about this conversion! What could be the appropriate syntax? thanks again!>> >have you tried looking at the help for fread? using bit12 or ubit12 as a>format? > >Best of luck - Mike > > >
Reply by ●April 10, 20062006-04-10
"Umutesi Faith" <ma_nz1@yahoo.com> wrote in message news:xYKdneCeBJAyjafZRVn-gQ@giganews.com...> > Hello > > Does anyone have a hint on how to convert a set of 12-bites unsigned > interger to float, using matlab? > Matlab shows the following syntax using float > > a = float('single') > a = float('double') > a = float(TotalBits, ExpBits) > > // here is an example of 12-bit unsigned int > x=[ > 2843 > 2845 > 2851 > 2869 > 2838 > 2840 > 2853 > 2864]; > > I have tried these 3 float syntaxes , but i don't get any conversion? > Any ideas on how to use them?? > Thanks in advance!All variables are stored as double precision floats in matlab by default. there is no unsigned int representation in Matlab (unless the latest and greatest release has some new data type). so if you did x = 2843; it will be stored as 2843.00 and x will be a floating point number. There is no specific syntax you need to do this. Cheers Bhaskar
Reply by ●April 11, 20062006-04-11
hi, thanks a lot, this at least helps!> >All variables are stored as double precision floats in matlab bydefault.>there is no unsigned int representation in Matlab (unless the latest and >greatest release has some new data type). > >so if you did >x = 2843; >it will be stored as 2843.00 and x will be a floating point number. Thereis>no specific syntax you need to do this. > >Cheers >Bhaskar > > > > > > > > >