MATLAB: Reading a portion of a binary file and saving it as a vector

fopen fseek fread binary

I am trying to extract a portion of a binary file (in this case position 0 to 3600) and save it as a vector (data) using the following code:
fid=fopen('filename.bin');
fseek(fid,3600,0);
data=fread(fid,'float');
But instead of reading the portion (0 to 3600) of the file, it reads the entire file and saves it to 'data'. Any ideas on how to approach this?
Thank you in advance!

Best Answer

fid = fopen('filename.txt');
data = fread(fid, 3600, 'float');
Please check the boundary condition: do you want 3600 items read, or do you want items #0 to #3600 read (3601 total items) ?