[scilab-Users] Re: reading file in hexadecimal

Mike Page Mike at Page-One.Waitrose.com
Tue Feb 8 17:56:00 CET 2011


Hi Loic,

Thinking about it, you might need to use an unsigned format ('ul') if any of your values are negative - dec2hex only works for positive numbers.  Anyway, you can try various things now you have a partial solution.

Mike.

  -----Original Message-----
  From: Loïc GIROD [mailto:Loic.Girod at esstin.uhp-nancy.fr]
  Sent: 08 February 2011 16:24
  To: users at lists.scilab.org
  Subject: [scilab-Users] Re: reading file in hexadecimal


  Hello Mike, 

   

  Many thanks for your answer.

  It works perfect with a = dec2hex (mget (1, ‘l’, fd)).

  I only need to read one float each time.

   

  Thank you again

   

  Loic

   

   

   

  Subject: Re: reading file in hexadecimal 

  From: "Mike Page" ####@####.#### 

  Date: 8 Feb 2011 10:54:36 +0100 

  Message-Id: <LKECIGCCKNOMMCKAGNOAAEMDDDAA.Mike at Page-One.Waitrose.com> 

  Hi Loic,

   

  Not sure what you want exactly, but the file looks like a set of floats

  (4-byte IEEE 754 floating point values).  You can read these using:

   

  a = mget (n, 'f', fd)

   

  where n is the number you want to read and fd is the file descriptor (you

  get that using fd=mopen("F1_31.dat",'rb').

   

  If you really want the values in hex, then it depends on how many bytes per

  hex value.  If there are 4 bytes each, then you can use something like:

   

  a = dec2hex (mget (n, 'l', fd))

   

  Hope that helps.

   

  Mike.

   

    -----Original Message-----

    From: Lo�c GIROD ####@####.####

    Sent: 08 February 2011 09:13

    To: ####@####.####

    Subject: [scilab-Users] reading file in hexadecimal

   

   

    Hello,

   

   

   

    Beginner under scilab, I�m trying to make a script to read a file and make

  some calculations on the data.

   

    I would like to read the file attached (F1_31) as an hexa format.

   

    For the moment, I use notepad++ to convert the file in hexadecimal and I

  can read it in scilab using mopen/mfscanf.

   

   

   

    I would like to be able to read the file directly under scilab, without

  using another software.

   

   

   

    Is it possible ?

   

   

   

    If yes, could you please explain me the procedure ?

   

   

   

    Best regards

   

   

   

   

   

    Loic

   

   

   

   

   

   

   

   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20110208/ab22c940/attachment.htm>


More information about the users mailing list