From: Jan Simon on 15 Feb 2010 10:26 Dear Andy! > My apologies, I appear to have explained this pretty poorly. By 16 and 32 bit long, I mean that a single file will be either 16 or 32 bit long, but I will require to read in both. An example of what I'm trying to read in is: The file is 16 or 32 bit long? Are you sure that you read 2 or 4 bytes only? Then your example is confusing: > 0000000000000000 > 0011010111011011 > 0011101000110010 > 0000100100001000 > 1100111110010001 > 1100001010100001 Are these bits, bytes or characters? > So far, I haven't found a way of using fread to be able to read this in correctly. The best suggestion I've had was to use fread(fid,'*char') and then perform bin2dec on that but I suspect I had a syntax problem because it said that character was too long. If you have a program, which causes an error message, please post the (relevant part) of it together with a copy of the error message! Then the newsgroup member can solve your particular problem and do not have to write the complete program... Kind regards, Jan
From: Big Andy Nicol on 15 Feb 2010 11:24
Thanks for everyone's input. Fortunately, our resident Matlab guru has managed to find a solution: fid = fopen ('./input1.dat') binarray = []; bincount = 1; while (feof(fid) ~= true) bin_num = fgetl(fid); binarray(bincount) = bin2dec(bin_num); bincount = bincount +1; end Sorry for all the trouble!! Andy |