On Thu, 30 Mar 2006, Wolfgang wrote: > Hello, > > yes I want to extract a matrix of 1024x1024 of binary data (2bytes for each > value). But ahead of this data is 1048576 bit (13312 bytes) of crap. I don't > know matlab at all and I don't like to start this routine when I want to > import that data into my application, which can not skip this header. If it > is easier to do by a linux command (its running in cygwin) any help is also > welcome. > > Wolfgang > > PS: I will also test the example of Robert ok. so, just to clarify, you want to read a 2mb matrix out of a file after skiping 13312 bytes of crap. this will do that def extract_data path open(path){|f| f.seek(13312); f.read(1024*1024*2)} end here data returned is a buffer. if you want a matrix object i __highly__ suggest installing the narray module and using something like require 'narray' def extract_matrix path na = NArray.sint 1024, 1024 open(path){|f| f.seek(13312); na[] = f.read(1024*1024*2)} na end this will return a numerical matrix with nice operators. you can write it to file with open('m.dat','w'){|f| f.write na} and this will write the matix in binary. regards. -a -- share your knowledge. it's a way to achieve immortality. - h.h. the 14th dali lama