[ncl-talk] How to combine multiple bytes into numeric types

Li Dong dongli at lasg.iap.ac.cn
Thu Aug 14 00:36:23 MDT 2014


Dear all,

When I read a binary file, which contains a head, I first need to get some information from the head. The head contains several variables in different types, such as in Fortran:

type head
    character(16) a
    integer(2) b
    real(4) c
end head

The binary file is written in C format (I think, it is from other guys). I tried to use `cbinread` to read the head as:

head = cbinread(“…”, 22, “character”)

So now I get an array of characters. The character string `a` can be easily extracted as:

a = charactertostring(head(0:15))

But what about `b` and `c`? How do I get them from head(16:17) and head(18:21)? I didn’t find some functions that can take several bytes and combine them to form other desired types.

Thanks in advance!

Best regards,

Li
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140814/d1dac4d4/attachment.html 


More information about the ncl-talk mailing list