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

📄 complot.m

📁 数字通信第四版原书的例程
💻 M
字号:
function complot(com_fig)
% COMPLOT

%       Copyright (c) 1995-96 by The MathWorks, Inc.
%       $Revision: 1.1 $  $Date: 1996/04/01 17:54:13 $

handle = get(com_fig, 'UserData');
if ~isempty(handle)
    h_axes = handle(1);
    h_plot = handle(2);
    testl  = handle(3:7);
    popmu  = handle(8:12);
    entr_text = handle(13:32);
    entr_valu = handle(33:52);
    exec = handle(53:63);
    data_h = handle(60:63);
    load_save = handle(64:67);
    bar_color = handle(68:69);
else
    error('The GUI figure is distroyed. Close the window and restart COMMGUI.');
end;

fig_name = ['plot for ', get(com_fig, 'Name')];
list = get(0, 'child');
fd = 0;
i = 1;
while ~fd & (i <= length(list))
  if strcmp(get(list(i), 'name'), fig_name)
    fd = list(i);
    set(0, 'CurrentFigure', list(i));
    tmp = get(fd,'child');
    for i = tmp(:)'
      if ~isempty(get(i,'child'))
        delete(get(i,'child'))
      end
      delete(i);
    end;
  else
    i = i + 1;
  end;
end;
if ~fd
  fd=figure('name', fig_name, ...
        'NumberTitle','off'...
        );
else
  set(fd,'NextPlot','add')
end;

ord = str2num(get(exec(5), 'String'));
for i = 1 : 4
    x1 = get(data_h(i), 'UserData');
    if ~isempty(x1)
        y1 = x1(2,:);
        x1 = x1(1,:);
        [x1, st] = sort(x1);
        y1 = y1(st);
        if i == 1
            loglog(x1, y1, 'y*');
            hold on
        elseif i == 2
            loglog(x1, y1, 'mx');
            hold on
        elseif i == 3
            loglog(x1, y1, 'c+');
            hold on
        elseif i == 4
            loglog(x1, y1, 'wo');
            hold on
        end;
        if ord > 0
           xx11=logspace(log10(min(x1)), log10(max(x1)));
           x1 = x1(y1>0);
           y1 = y1(y1>0);
           if length(y1) <= ord
               disp('Warning: data length is too few to fit your specified order.')
               p = polyfit(log10(x1), log10(y1), length(y1) - 1);
           else
               p = polyfit(log10(x1), log10(y1), ord);
           end;
           yy1 = polyval(p, log10(xx11));
           if i == 1
               loglog(xx11, 10 .^yy1, 'y-');
           elseif i == 2
               loglog(xx11, 10 .^yy1, 'm-');
           elseif i == 3
               loglog(xx11, 10 .^yy1, 'c-');
           elseif i == 4
               loglog(xx11, 10 .^yy1, 'w-');
           end;
        else
           if i == 1
               loglog(x1, y1, 'y-')
           elseif i == 2
               loglog(x1, y1, 'm-')
           elseif i == 3
               loglog(x1, y1, 'c-')
           elseif i == 4
               loglog(x1, y1, 'w-')
           end;
        end;
    end;
end;

hold off
xlabel('Signal/Noise Ratio');
ylabel('Bit Error Rate');
zoom on

%f_ax = get(fd,'child');
%
%set(fd, 'windowbuttondownfcn', 'complot2(0)', 'unit','norm','interruptible','yes',...
%        'nextplot','add')
%line = axes('position',[0 0 1 1]);
%line = plot(NaN, NaN, 'g:');
%set(line,'EraseMode','xor');
%set(get(line,'parent'), 'visible','off','Nextplot','add',...
%    'Xlim',[0 1], 'Ylim',[0 1]);
%set(fd, 'UserData', [f_ax, line, get(f_ax,'Xlim'), get(f_ax,'Ylim')],...
%        'nextplot', 'new')
% end complot

⌨️ 快捷键说明

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