www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/WriteComplexDataExample.m

    %% Write Complex Data
% This example shows how the |dsp.BinaryFileWriter| object writes complex
% data.

%% 
% Create a |dsp.BinaryFileWriter| object which writes to a file named 
% 'myfile.dat'. There is no header. The data is complex. 
writer = dsp.BinaryFileWriter('myfile.dat');
data = [1 2 3 4]+1i*[5 6 7 8];
writer(data);
release(writer);


%% 
% Read the data using the |dsp.BinaryFileReader| System object(TM). To view 
% data in the format it is written to the file, set the |IsDataComplex| 
% property to |false|. The reader object reads the data as a sequence of 
% numbers in a row major format. Set |SamplesPerFrame| to 1 and
% |NumChannels| to 8.

reader = dsp.BinaryFileReader('myfile.dat','SamplesPerFrame',1,...
    'NumChannels',8);
s = struct([]);
reader.HeaderStructure = s;
dataRead = reader();

%%
% You can see that the real and imaginary components of the original data
% are sample interleaved.
display(dataRead);