ofdm simulation

  • l4_405721
    了解作者
  • 149.6KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 02:46
    上传日期
this is a ofdm matlab silulation.
33753166ofdm.zip
  • IEEE80211a_graphics.m
    7.6KB
  • IEEE80211a_udg.m
    4.1KB
  • IEEE80211a_open_graphics.m
    494B
  • IEEE80211a_sfun.dll
    152KB
  • IEEE80211a_graphics.fig
    290.9KB
  • IEEE80211a.mdl
    254.1KB
  • IEEE80211a_NoSF.mdl
    239.4KB
  • IEEE80211a_lib.mdl
    21.5KB
  • IEEE80211a_settings.m
    2.3KB
  • IEEE80211a_init.mat
    3.5KB
内容介绍
function IEEE80211a_graphics(s, ax, firstcall, params); % IEEE80211A_GRAPHICS Update MATLAB graphics from IEEE 802.11a simulation. % ieee80211a_graphics(s, ax, firstcall, params) updates axes. % % s: structure, containing data corresponding to multiple matrices % ax: structure of axes handles % firstcall: first plot % params: modulation parameters % handles haxes = cell2mat(struct2cell(ax)); fig = get(haxes(1), 'parent'); % Create structure, d, containing all data required by plotting functions % part of d is stored in guidata d = guidata(fig); if firstcall % set axes-related handles d.axes_handles = haxes; d.num_axes = length(d.axes_handles); d.axes_tags = get(d.axes_handles, 'tag'); for n = 1:d.num_axes d.plotfn_handles(n) = str2func(['plot_' d.axes_tags{n}]); end d.frame_number = 1; d.txdata_xrange = 1:256; d.block_Npoints = 50; d.block_x_range = 1:d.block_Npoints; d.block_y_init = uNaN(1, d.block_Npoints); else d.frame_number = d.frame_number + 1; end guidata(fig, d); % Pre-computation link_delay = 34; speceff = params.bitsPerSymbol(s.mode); % spectral efficiency d.first_frame = (d.frame_number == 1); d.block_full = (d.frame_number > d.block_Npoints); d.bit_period = params.bitPeriod(s.mode); d.txbits = s.txbits.'; d.magresp = s.magresp.'; d.eqresp = s.eqresp.'; d.prerxg = s.prerxg.'; d.postrxg = s.postrxg.'; d.estSNRdB = s.estSNRdB.'; d.bitrate = 54*speceff/4.5; % 802.11a-specific d.ber = calcBER(s.txbits, s.rxbits, params.bitsPerBlock(s.mode), link_delay); % alternative: call each function explicitly, with its axes handle for i = 1:d.num_axes feval(d.plotfn_handles(i), firstcall, d.axes_handles(i), d); end %-------------------------------------------------------------------------- % Plot functions (one for each axes object) % For object xyz, corresponding function name is plot_xyz %-------------------------------------------------------------------------- function plot_txdata(fc, ax, d); tmax = 5e-6; % maximum time (needs to be consistent with axis limits) x = 0:d.bit_period:tmax; y = d.txbits(1:(length(x)-1)); plot_data_sequence(fc, ax, x, y, 50); %-------------------------------------------------------------------------- function plot_prerxg(fc, ax, d); plot_constellation(fc, ax, d.prerxg, 3); %-------------------------------------------------------------------------- function plot_postrxg(fc, ax, d); plot_constellation(fc, ax, d.postrxg, 5); %-------------------------------------------------------------------------- function plot_avSNRdB(fc, ax, d); y_append = d.estSNRdB; plot_signal_evolution(fc, ax, d.block_x_range, y_append, {'.-', 'm-'}); %-------------------------------------------------------------------------- function plot_throughput(fc, ax, d); y_append = d.bitrate; plot_signal_evolution(fc, ax, d.block_x_range, y_append, {'r.-'}); %-------------------------------------------------------------------------- function plot_freqResp(fc, ax, d); y = fftshift(d.magresp); plot_real_sig(fc, ax, y); %-------------------------------------------------------------------------- function plot_eqResp(fc, ax, d); y = [uNaN(1,6) d.eqresp uNaN(1,5)]; plot_real_sig(fc, ax, y); %-------------------------------------------------------------------------- function plot_ber(fc, ax, d); y_append = [0 d.ber 0] + eps; ii = 3*(d.frame_number - 1) + (1:3); if fc init_axes(ax) x = d.block_x_range; x = [x; x; x]; x = x(:).'; y = uNaN(1, length(x)); y(ii) = y_append; plot(x, y, '-', 'linewidth', 2); else y = get_line_data(ax); if ~d.block_full y(ii) = y_append; else y = [y(4:end) y_append]; end set_line_data(ax, {y}); end %-------------------------------------------------------------------------- % Support functions %-------------------------------------------------------------------------- function ber = calcBER(txbits, rxbits, bits_per_block, link_delay); % calculate bit-error-rate, expressed as percentage txb = txbits( 1 : bits_per_block-link_delay ); rxb = rxbits( link_delay+1 : bits_per_block ); [Nbits, Nv] = size(txb); decisionerror = rxb~=txb; nerrors = nnz(decisionerror); ber=nerrors/Nbits; %-------------------------------------------------------------------------- function plot_data_sequence(fc, ax, x, y, Nmax); x = [x; x]; x = x(:).'; x = x(2:(end-1)); y = [y; y]; y = y(:).'; u = uNaN(1, 2*Nmax - length(x)); x = [x u]; y = [y u]; if fc init_axes(ax); plot(x, y, '-'); else c = get(ax, 'child'); set(c, 'xdata', x, 'ydata', y); end %-------------------------------------------------------------------------- function plot_real_sig(fc, ax, y); if fc Lx = length(y); x = (1:Lx)-Lx/2 - 1; init_axes(ax); plot(x, y, '-', 'linewidth', 2); else c = get(ax, 'child'); set(c, 'ydata', y); end %-------------------------------------------------------------------------- function plot_constellation(fc, ax, x, marker_size); if fc init_axes(ax); plot(x, '.', 'markersize', marker_size); else c = get(ax, 'child'); set(c, 'xdata', real(x)); % for speed set(c, 'ydata', imag(x)); end %-------------------------------------------------------------------------- function plot_signal_evolution(fc, ax, x, y_append, linetypes); % if fc: x is not used if fc init_axes(ax); n = 1; % x index number y = uNaN(1, length(x)); y = [y; y]; y(:, n) = y_append; if length(y_append)==2 plot(x, y(1,:), linetypes{1}, x, y(2,:), linetypes{2}); else plot(x, y(1,:), linetypes{1}); end set(ax, 'userdata', n); else n = get(ax, 'userdata') + 1; yc = get_line_data(ax); if length(y_append)==2 y = [yc{1}; yc{2}]; else y = yc; end if n <= size(y, 2) y(:, n) = y_append; else y = [y(:, 2:end) y_append]; end set_line_data(ax, {y}); set(ax, 'userdata', n); end %-------------------------------------------------------------------------- % General functions %-------------------------------------------------------------------------- function y = uNaN(M,N); uNaN = NaN; y = uNaN([ones(M,N)]); %-------------------------------------------------------------------------- function init_axes(ax); axes(ax) cla hold on % needed if followed by plot command %-------------------------------------------------------------------------- function yd = get_line_data(ax); % yd is cell array of ydata, in reverse order of axes children c = get(ax, 'child'); nc = length(c); if nc==1 yd = get(c, 'ydata'); else cr = 1:nc; yr = fliplr(cr); yd = cell(1, nc); for i = cr yd{yr(i)} = get(c(i), 'ydata'); end end %-------------------------------------------------------------------------- function set_line_data(ax, ld, mode); % ld is cell array of line data, in reverse order of axes children % if mode = 'complex', does ld is assumed to be ydata, otherwise complex data if nargin==2, mode = 'ydata'; end if strcmp(mode, 'ydata') set_ydata(ax, ld); else set_complexdata(ax, ld); end %-------------------------------------------------------------------------- function set_ydata(ax, yd); % yd is cell array of ydata, in reverse order of axes children c = get(ax,'child'); s = length(yd); cr = 1:s; yr = fliplr(cr); k = 1; for i = cr ydi = yd{yr(i)}; s2 = size(ydi, 1); yr2 = fliplr(1:s2); for m = 1:s2 set(c(k), 'ydata', ydi(yr2(m),:)); k = k+1; end end
评论
    相关推荐
    • matlab 课件
      matlab 功能很强大,本课件详细的介绍了matlab在科学计算中的应用。
    • Matlab教程
      MatlaB经典ppt,主要讲解了MatlaB的入门知识,图形编程以及仿真。
    • matlab入门
      matlab的入门教程,很值得仔细看看,对提高matlab能力有帮助
    • matlab编译器
      matlab编译为exe文件所需要的文件; 使用时解压,将解压后文件拖入至matlab命令行即可
    • matlab
      matlab的基础知识进行介绍
    • MatLab
      “#MatLab
    • MATLAB编译器
      基于MATLAB 2018b版本介绍MATLAB编译器。介绍如何利用编译器将MATLAB代码编译为独立应用程序或组件,并在没有安装MATLAB的计算机上进行部署。
    • MATLAB 论文
      基于MATLAB的论文撰写!可以为你指明一条写作MATLAB论文的道路!
    • matlab
      matlab经典课堂讲义
    • matlab
      matlab