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

📄 pertone.m

📁 多载波调制的仿真程序
💻 M
📖 第 1 页 / 共 3 页
字号:
   end   set(gco,'Userdata',vv,'String',num2str(vv))   return      % set margin   elseif strcmp(action,'setMargin'),   hndlList=get(gcf,'Userdata');   v = get(gco,'Userdata');   s = get(gco,'String');   vv = eval(s,num2str(v(1)));   % do not allow negative margin   if vv < 0,       vv = v;    end   set(gco,'Userdata',vv,'String',num2str(vv))   return      % set input power   elseif strcmp(action,'setPwr'),   hndlList=get(gcf,'Userdata');   v = get(gco,'Userdata');   s = get(gco,'String');   vv = eval(s,num2str(v(1)));   % do not allow negative input power   if vv < 0,       vv = v;    end   set(gco,'Userdata',vv,'String',num2str(vv))   return      % set white noise power   elseif strcmp(action,'setAWGN'),   hndlList=get(gcf,'Userdata');   v = get(gco,'Userdata');   s = get(gco,'String');   vv = eval(s,num2str(v(1)));   % do not allow negative noise power   if vv > 0,       vv = v;    end   set(gco,'Userdata',vv,'String',num2str(vv))   return      % set channel number   elseif strcmp(action,'setCSA'),   hndlList=get(gcf,'Userdata');   v = get(gco,'Userdata');   s = get(gco,'String');   vv = eval(s,num2str(v(1)));   % only have 8 CSA channel numbered 1-8   if vv < 1 | vv > 8,       vv = v;    end   set(gco,'Userdata',vv,'String',num2str(vv))   return      % set Dmin   elseif strcmp(action,'setDmin'),   hndlList=get(gcf,'Userdata');   Dmax = get(hndlList(8),'Userdata');   v = get(gco,'Userdata');   s = get(gco,'String');   vv = eval(s,num2str(v(1)));   % Dmin cannot be smaller than 1 and larger than Dmax   if vv<1 | vv > Dmax,       vv = v;    end   set(gco,'Userdata',vv,'String',num2str(vv))   return      % set Dmax   elseif strcmp(action,'setDmax'),   hndlList=get(gcf,'Userdata');   Dmin = get(hndlList(7),'Userdata');   v = get(gco,'Userdata');   s = get(gco,'String');   vv = eval(s,num2str(v(1)));   % Dmax cannot be smaller than 1 and Dmin   if vv < 1 | vv < Dmin,       vv = v;   end   set(gco,'Userdata',vv,'String',num2str(vv))   return      % set N   elseif strcmp(action,'setN'),   hndlList=get(gcf,'Userdata');   v = get(gco,'Userdata');   s = get(gco,'String');   vv = eval(s,num2str(v(1)));   % N has to be a power of 2   if (floor(log(vv)/log(2))-(log(vv)/log(2))) ~= 0      vv = v;    end   set(gco,'Userdata',vv,'String',num2str(vv))   return      % design TEQ   elseif strcmp(action,'design'),   set(gcf,'Pointer','watch');   % get handles   axHndl=gca;   fhndlList=get(gcf,'Userdata');   freqzHndl = fhndlList(1);   TGHndl = fhndlList(2);   NwHndl = fhndlList(3);   NHndl = fhndlList(4);   CGHndl = fhndlList(5);   MarginHndl = fhndlList(6);   DminHndl = fhndlList(7);   DmaxHndl = fhndlList(8);   PwrHndl = fhndlList(9);   AWGNHndl = fhndlList(10);   CSAHndl = fhndlList(11);   viewHndl = fhndlList(12);   helpHndl = fhndlList(13);   closeHndl = fhndlList(14);   methodHndl = fhndlList(15);   methRateHndl = fhndlList(16);   methSNRHndl = fhndlList(17);   methSSNRHndl = fhndlList(18);   methMSEHndl = fhndlList(19);   methDelayHndl = fhndlList(20);   methMaxHndl = fhndlList(21);      colors = get(gca,'colororder');      % init variables   TG = get(TGHndl,'userdata');   Nw = get(NwHndl,'userdata');   N = get(NHndl,'userdata');   codingGain = get(CGHndl,'userdata');   margin = get(MarginHndl,'userdata');   Dmin = get(DminHndl,'userdata');   Dmax = get(DmaxHndl,'userdata');   totalInputPower = get(PwrHndl,'userdata');   AWGNpower = get(AWGNHndl,'userdata');   loopNum = get(CSAHndl,'userdata');   method = get(methodHndl,'value');   barflag = 1;   %number of iteration per TEQ tap   numIter = 1000;      %generate signal,noise, and channel data   [recNoisySig,receivedSignal,noise,channel,inputSignal,gamma,fs, FX] = ...      siggen_pertone(N,AWGNpower,loopNum,totalInputPower,codingGain,margin,barflag);    %save tmp1.mat inputSignal, receivedSignal, noise;   %estimate the power spectrums   [inputSpecAll, noiseSpecAll, channelGainAll]=...      specestim(inputSignal,noise,channel,N,barflag);      %calculate SNRs and usable channels   [subMFBall,subMFB,usedSubs,noiseSpec,channelGain,inputSpec] = ...   calcsnrs(inputSpecAll,channelGainAll,noiseSpecAll,gamma);   %chose method and design pertone   [WM, D, title_str, py, pX] = selmeth_pte(method,FX,...   receivedSignal,noise,channel, Nw, N, barflag);      save designtemp WM D title_str py pX      %load designtemp;      Xhat = pertoneeq(WM.',py);   [subSNR, Ps, Pn] = snr_pte(pX, Xhat, usedSubs);      bmap(usedSubs) = ba_cal(subSNR(usedSubs), 9.8, margin, codingGain, 0, 100, 0);      RDMTfinal = 4312.5*sum(bmap);      bmfb(usedSubs) = ba_cal(subMFBall(usedSubs), 9.8, margin, codingGain, 0, 100, 0);   RDMTmfb = 4312.5*sum(bmfb);   % get performance results   %[SSNR, SNR, subSNR,geoSNRfinal,geoSNRmfb,bDMTfinal,bDMTmfb,...    %     RDMTfinal,RDMTmfb,hw,Fh,Fw,colorNoiseaft,Fhw] = ...     % perform(W,B,channel,D,Nb,N,inputSignal,noise,...      %channelGainAll,inputSpecAll,noiseSpecAll,margin,codingGain,fs,subMFBall,usedSubs);      % put results into table   str = sprintf('%1.3fe6',RDMTfinal/1e6);   set(methRateHndl,'string',str);   str = '-';   set(methSNRHndl,'string',str);   str = '-';   set(methSSNRHndl,'string',str);   str = '-';   set(methDelayHndl,'string',str);   str = '-';   set(methMSEHndl,'string',str);   str = sprintf('%1.3fe6',RDMTmfb/1e6);   set(methMaxHndl,'string',str);         % save resuls to disk in order to use it in other functions    save tmpresults subMFBall subSNR N usedSubs title_str noiseSpec noiseSpecAll      %TEQequalizerTaps = W;   %TEQtargetImpulseResp = B;   %TEQoptimalDelay = D;   %TEQoriginalChannel = channel;   %TEQequalizedChannel = hw;   %TEQmatchedFilterBoundPerChannel = subMFB;   %TEQSNRperChannel = subSNR;   %TEQoriginalChannelFreqResp = Fh;   %TEQequalizerFreqResp = Fw;   %TEQequalizedChannelFreqResp = Fhw;   %TEQchanNoisePowSpecAfterEqual = colorNoiseaft;   %TEQchanNoisePowSpecBeforeEqual = noiseSpec;   %TEQperformanceVersusDelay = Dv;   %TEQDmin = Dmin;   %TEQDmax = Dmax;   %TEQNb = Nb;   %TEQNw = Nw;   %TEQN = N;      %save teqresults TEQequalizerTaps TEQtargetImpulseResp  ...	   %TEQoptimalDelay TEQoriginalChannel TEQequalizedChannel ...	   %TEQmatchedFilterBoundPerChannel TEQSNRperChannel ...	   %TEQoriginalChannelFreqResp TEQequalizerFreqResp ...	   %TEQequalizedChannelFreqResp TEQchanNoisePowSpecAfterEqual...	   %TEQchanNoisePowSpecBeforeEqual TEQDmin TEQDmax TEQNb TEQNw TEQN;	      % plot result   pertone('plotGraph');   set(gcf,'Pointer','arrow');   return      % plot graphelseif strcmp(action,'plotGraph'),  legend off  set(gcf,'Pointer','watch');   % get handles   fhndlList = get(gcf,'Userdata');   viewHndl = fhndlList(12);   freqzHndl = fhndlList(1);   % set axis   axHndl = gca;   axes(freqzHndl);   % which graph is going to be ploted   graphNum = get(viewHndl,'value');    %1= TIR/SIR, 2= TEQ impulse res., 3= TEQ freq. res., 4= SNR/MFB   %5=original and short channel impulse res, 6 = noise power spec.,    %7= delay plot, 8= equalized channel freq      % load results for current TEQ   load tmpresults;   freqAxis = 1:N/2+1;      % plot chosen grap   if graphNum == 1      legend off      plot(freqAxis(usedSubs),10*log10(subSNR(usedSubs)+eps))      hold on;      plot(freqAxis(usedSubs),10*log10(subMFBall(usedSubs)+eps),'r')      hold off      grid on      axisSet = axis;      axisSet(1) = min(freqAxis(usedSubs))-2;      axisSet(2) = max(freqAxis(usedSubs))+2;      axis(axisSet);      xlabel('frequency')      ylabel('magnitude (dB)')      title([title_str,' achieved and upper-bound SNR'])      legend('SNR','MFB',0);        elseif graphNum == 2      legend off      plot(freqAxis(usedSubs),20*log10(noiseSpecAll(usedSubs)+eps),'r')      grid on	      axisSet = axis;      axisSet(1) = min(freqAxis(usedSubs))-2;      axisSet(2) = max(freqAxis(usedSubs))+2;      axis(axisSet);      xlabel('frequency')      ylabel('magnitude (dB)')      title([title_str,' Noise Power Spectrum'])      legend('before TEQ','after TEQ',0);           end      set(gcf,'Pointer','arrow');   return      % get helpelseif strcmp(action,'info'),   ttlStr = get(gcf,'name');   myFig = gcf;      topic1 =  ['Per Tone design demo'];   helptop1 = [...     'This demo lets you design Per Tone equalizers and analyze their       '     'performance.                                                          '     '                                                                      '     'Usage: Set parameters to desired values and hit the Calculate button. '     '                                                                      '     'The following design methods are supported:                           '	 '  Least squares matching of frequency domain input-output.            '		  	 ];      topic2 =  ['Design and Simulation Paramters'];   helptop2 = [...	 'On the top of he control window on the right is a pulldown menu       '     'from which a design method can be chosen.                             '	 'Below this pulldown menu are the following editable text windows      '     'which are used to set the desired parameters,                         '     '  Tones per group. Set the tones for each group.                      '     '   Per tone equalizer length. Defines the number of taps of           ' 	 '   the equalizer for each tone.                                       '     '  Fast Fourier transform (FFT) size. Sets the FFT size used in DMT    '     '   modulation. It is twice the number of subchannels.                 '     '  Coding gain (dB). Defines a coding in dB used during capacity       '     '   calculations.                                                      '     '  Margin (dB). Sets the desired system margin in dB. This is also     '     '   used in capacity calculations.                                     '     '  Dmin and Dmax. The optimal delay is search in the interval between  '     '   Dmin and Dmax.                                                     '	 '  Input power (dBm). Defines the input signal power in dBm.           '	 '  AWGN pow (dBm/Hz). Sets the amount of additive white Gaussian noise '     '   in dBm/Hz. AWGN is added to the near-end crosstalk noise.          '     '  CSA loop \# (1-8). Selects the desired channel to run the simulation'     '   on. Currently 8 standard CSA loops are supported.                  '];        topic3 =  ['Graphics'];   helptop3 = [...	 'Below the editable text windows is another pull-down menu which       '     'is used to select the desired graph to be displayed.                  '     'The following graphics can be selected:                               '     '  SNR & MFB. The SNR and matched filter bound to the SNR is displayed '     '   as a function of frequency (subchannels).                          '     '  Noise Power Spectrum. Shows the power spectrum of the noise which   '     '   consists of NEXT noise plus AWGN.                                  '     ];    topic4 =  ['Performance Measures'];   helptop4 = [...'The two remaining buttons in the control frame are                    ''   Info. Displays this help.                                          ''   Calculate. Starts the calculation and performance evaluation of the''    TEQ.                                                              ''The following performance measures are calculated and listed in the   ''table:                                                                ''   Rate. Gives the achievable bit rate with the given channel and Per ''    Tone Equalizers settings.                                         ''   Max Rate. Shows the absolute maximum achievable bit rate given the ''    channel and equalizer settings. It is basically the capacity      ''   calculated from the MFB.                                           '];		    str =  { topic1 helptop1; topic2 helptop2; topic3 helptop3; topic4 helptop4 };      helpwin(str,'Topic 1','Per Tone design demo')                      return     else   disp(sprintf( 'Internal ERROR: ''%s'' not recognized',action))end     

⌨️ 快捷键说明

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