I've got a .dat file which I load into my program by such a formula:
fread(FID, 4, 'uint8');
Data = fread(FID, [1, 4092], 'uint8');
Calib = Data(4:4:end); % Pierwsza czesc pliku - kalibracja
fread(FID, 4, 'uint8');
Data = fread(FID, [4096, 204600], 'uint8');
x1 = Data(1:2:204600);
The problem is that after 4092 bytes there're 16 bytes that I need to skip and continue loading the following data. A this happens every 4092 bytes. Is there any way to solve this problem? Will be grateful for any help.

 採用された回答

Walter Roberson
Walter Roberson 2012 年 2 月 5 日

0 投票

Use the precision and skip parameters http://www.mathworks.com/help/techdoc/ref/fread.html
'4092*uint8', 16

3 件のコメント

Olga
Olga 2012 年 2 月 6 日
Thanks a lot. But there's one problem - this cuts only the first 16 bytes after 4092 good ones, but it doesn't cut the rest in the following sequences. Why is that?
Walter Roberson
Walter Roberson 2012 年 2 月 6 日
Hmmmm, that is not what "help fread" says should happen. The help information says specifically that the skip will be re-used. Which MATLAB version are you using? I am looking at the information for 2008b and for 2011b.
Side issue: do you perhaps want to be using 'uint8=>uint8' ? Your current code reads uint8 and converts them to double. To keep as uint8 with the skip,
'4092*uint8=>uint8', 16
Olga
Olga 2012 年 2 月 7 日
Exactly help says that it'll skip the value SKIP after each PRECISION value. That's why I don't know why it doesn't.
I'm usin version 2010a version of MATLAB.
Thanks for the last suggestion, I've missed it.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2012 年 2 月 5 日

編集済み:

Jan
2013 年 10 月 2 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by