필터 지우기
필터 지우기

How to read data file in batch until end of file and write results in an array

조회 수: 1 (최근 30일)
Ivy Chen
Ivy Chen 2017년 10월 10일
편집: per isakson 2017년 10월 11일
I need to read a large bin file in batches. Assuming the batch size is 5000 and will take an average over K (100 in this case) bin. At the end of process, I will have a number of averages to plot.
Have the basic code (first 5000 batch) below and now I have a couple of questions to proceed:
%%Process and Plot rf.bin
filename='rf.bin'; % filename='./rf.bin';
fid=fopen(filename,'r');
dataHeader=fread(fid,123,'uint8'); %skipping the header for .bin
NsperBatch = 0.5e4; % number of sample per batch
magSpectrum=0;
for k=1:100 % There are roughly 13243 sets
data=fread(fid,NsperBatch*2,'int16','b'); %16 bit integer big endian
dataIQ=data(1:2:end)+1i*data(2:2:end); %convert to complex IQ
dataSpectrum=fftshift(fft(dataIQ)); %convert to frequency domain
magSpectrum = magSpectrum + abs(dataSpectrum).^2;
end
magSpectrum = magSpectrum/100;
z=pow2db(magSpectrum); %convert magnitude to DB
fclose all;
1. How do I continue to read until end of file. Roughly, there are about 13243 sets/batches until end of file
2. How do I store all end results in an array (like Z=[5000, 13243]), so they can support the 3D plot later.
thanks!

답변 (0개)

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by