Remove specific data sequence when reading .bin file
古いコメントを表示
How do I remove/skip the specific data sequence [1024 0 2240 -24500] when reading the .bin file in batch? thanks!
filename='rf.bin'; % filename='./rf.bin';
fid=fopen(filename,'r');
dataHeader=fread(fid,123,'uint8'); % skipping the header for .bin
NsperBatch = 1e3; % number of sample per batch
K=100; % Average every K set of values, K=100 in this case
magSpectrumMat=[];
while ~feof(fid)
magSpectrum=0;
for k=1:K
data=fread(fid,NsperBatch*2,'int16','b');
dataIQ=data(1:2:end)+1i*data(2:2:end);
dataSpectrum=fftshift(fft(dataIQ));
magSpectrum=magSpectrum+abs(dataSpectrum).^2;
end
magSpectrum = magSpectrum/K;
magSpectrumMat = [magSpectrumMat magSpectrum];
end
magSpectrumMat_dB=pow2db(magSpectrumMat);
3 件のコメント
Walter Roberson
2017 年 10 月 12 日
Where in the file can it occur? Can it appear just anywhere, like in the middle of a block of NsperBatch*2 values, and you want the code to notice and drop that from the sequence of values and read four more values to make up for the ignored data?
Walter Roberson
2017 年 10 月 12 日
Is there any possibility that it could occur inside the 123 byte header? Is there any possibility it could start inside the 123 byte header but end outside the header?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Correlation and Convolution についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!