⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 detect.m

📁 MIMO and VBLAST( please see the documentation)
💻 M
字号:
function varargout = detect(sig,lt_data,lt_state,ch_coefs,samples,...  smplper,gain,pulse,varargin)%DETECT Multidimensional Viterbi hard decision detector.%   DATA_EST = DETECT(SIG,LT_DATA,LT_STATE,CH_COEFS,SAMPLES,SMPLPER%   ,GAIN,PULSE) returns the data estimations based on look-up%   tables LT_DATA and LT_STATE. An external function BRMET is called%   during the computation to evaluate branch metric. CH_COEFS includes%   a channel complex path fadings; SAMPLES corresponds to the samples %   per symbol; GAIN corresponds to the constellation expansion factor%   computed by the SCALE function and PULSE contains the samples of%   modulation impulse sampled at frequency SMPLFREQ = 1 / SMPLPER.%%   [DATA_EST,STATE_EST] = DETECT(...) also returns matrix with trellis%   states of most probable path. This matrix is required when the%   decoding process is displayed with DISPTRELL function.%%   DATA_EST = DETECT(...,'EchoOn') toggles function echo on. When%   'EchoOn' option is chosen than a summary in form below is displayed.%%      DETECT:    Performing data detection. This may take a while.%                 Please wait...%                 Total decoding complexity -> ? steps.%                 Total elapsed time -> ? hrs, ? min, ? sec.%%   See also BRMET, DISPTRELLIS, MAKEPULSE, SCALE.%   Copyright 2001-2002 Kamil Anis, anisk@feld.cvut.cz%   Dept. of Radioelectronics, %   Faculty of Electrical Engineering%   Czech Technical University in Pragu%   $Revision: 2.0 $  $Date: 2002/10/23 17:33:28 $%   --%   <additional stuff should go here>if (isempty(varargin) == 0) & (varargin{end} == 'EchoOn')	[indent,gap,name] =  iprompt('DETECT:');		disp(' ');	disp([name,gap,'Performing data detection. This may take a while.']);	disp([indent,'Please wait...']);end[sig_length,space_dim,frames] = size(sig);[s,md,space_dim] = size(lt_data);load qam16.txt;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BODY BEGIN %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%tic;for k = 1:frames	% passing the signal through matched filter  clear sig_mf;	for j = 1:space_dim    sig_mf(:,j) = smplper * conv(pulse,sig(:,j,k)) / gain;	end  % omiting the sig begining to prevent of insecure decisions	delay = length(pulse);	sig_mf = sig_mf(delay:end-delay,:,:);	% sampling at symbol period (Ns in Dt)	sig_down = downsample(sig_mf,samples);	[step_final,foo] = size(sig_down);	% running multi-dimensional Viterbi algorithm	% make all starting paths unprobable except for the correct one	metric(1,2:s) = realmax;	for l = 1:step_final		for j = 1:s % current j		% finding all previous states s_pre leads to current sate j		[s_pre,foo] = find(lt_state == j);		% determining a pair position relevant to the state j		% {1,2,3,4,5,6,7,8} -> {1,2,3,4,1,2,3,4}		pos = mod(j - 1,md) + 1;		% picking-up the pairs corresponding to each of s_pre states		data_test = lt_data(s_pre,pos,:);		data_test = reshape(data_test,[md space_dim]);		% mapping pairs to appropriate constellation		if md == 16 % 16QAM			for r = 1:space_dim				k1(:,r) = qam16(data_test(:,r) + 1,1);				k2(:,r) = qam16(data_test(:,r) + 1,2);			end			q_test = (2 * k1 - md - 1) - i * (2 * k2 - md - 1);		else % 4,8PSK			expr = i * 2 * pi / md;			q_test = exp(expr * data_test);		end		% evaluating branch metric		metric_d = brmet(sig_down(l,:),q_test,ch_coefs(:,:,k));		% adds the data_test metrices to the previous states		metric_md = metric(l,s_pre)' + metric_d;		% choosing a metric with lowest accumulated value		[metric_min,metric_pos] = min(metric_md);		% and storing it's value to the matrix of metrices		metric(l + 1,j) = metric_min;		% creates a states matrix of s_pre (with lowest metric)		vit_state(l + 1,j) = s_pre(metric_pos);		% creates a matrix of appropriate data_test		vit_data(l + 1,j) = pos - 1;		end	end	% finding the best path at the trellis end	[foo,state_best] = min(metric(end,:));	state_est(step_final + 1) = state_best;	% back tracking	for l = step_final:-1:1		state_est(l) = vit_state(l + 1,state_est(l + 1));		data_est(l,:,k) = vit_data(l + 1,state_est(l + 1));	endendtotaltime = toc;varargout = {data_est,state_est};%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BODY END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%if (isempty(varargin) == 0) & (varargin{end} == 'EchoOn')	hour = round(totaltime / 3600);	mins = round(totaltime / 60);	secs = mod(totaltime,60);		str1 = num2str(frames * sig_length * s);	str2 = sprintf('%1d',hour);	str3 = sprintf('%1d',mins);	str4 = sprintf('%1.1f',secs);		disp([indent,'Total decoding complexity -> ',str1,' steps.']);	disp([indent,'Total elapsed time -> ',str2,' hrs, ',str3,' min, ',str4,...        ' sec.']);	disp(' ');end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -