0
ファイルからビットを読み取り、それらを複素数倍に変換したいとします。各数値は32ビット(16 Reと16 Im)です。次に、qamdemodを使用して1つの複素数あたり6ビットを得て、そのビットを新しいテキストファイルに保存したいとします。 私はプログラムが、私は常にプログラムで出力010011 = 50 と同じ番号を取得することにしました:64QAM復調 - 常に同じ出力を得ます。
% % Main Algorithm
N=16; %length of one sample
RUNTIME = input('How long you want to run in sec=');
prompt = '0 - for sequentially. 1 - for randomaly =';
n = input(prompt);
x=0;
switch n
case 0
timerID = tic; %# Start a clock and return the timer ID
disp('sequentially');
fid=fopen('rand.bin'); %need to check if file opened
fid_w=fopen('samples.txt','w'); %write to file
while true
%# Perform process
Re=fread(fid,N);
Re=Re'; %transpose to row vector
Im=fread(fid,N);
Im=Im'; %transpose to row vector
if size(Re)~=N
disp('Re is out of range');
break;
end
if size(Im)~=N
disp('Im is out of range');
break;
end
Re_dec=bi2de(Re);
Im_dec=bi2de(Im);
in = (Re_dec/65535) + (Im_dec*(1i)/65535); % unit circle 65535
double(in);
disp("IN:");
disp(in);
out = qamdemod(in,64);
data_out = de2bi(out);
disp(data_out);
fprintf(fid_w,'%f\n',in); %write to sample file
if (feof(fid))
disp('end of file');
break;
end
if(toc(timerID) > RUNTIME) %# Get the elapsed time for the timer
disp('end of time');
break;
end
end
case 1
disp('randomaly')
otherwise
disp('error')
end
fclose('all'); %close all open files
% out = lteSymbolDemodulate(in,'64QAM');