📄 commgui.m
字号:
function commgui(name, fileload)
%COMMGUI communication GUI top level file.
%
% Wes Wang 1996.
% Copyright (c) 1995-96 by The MathWorks, Inc.
% $Revision: 1.1 $ $Date: 1996/04/01 17:53:31 $
% assign the name
if nargin < 1
name = 'communication error rate estimation';
end;
% search if the figure exist.
fig_exist = get(0, 'child');
existing = 0;
if ~isempty(fig_exist)
i = 1;
while (~existing & i <= length(fig_exist))
if strcmp(get(fig_exist(i), 'name'), name)
existing = fig_exist(i);
end;
i = i + 1;
end;
end;
% open the figure
if ~existing
%create figure
default_color = get(0, 'defaultuicontrolbackgroundcolor');
default_color = [.5 .5 .5];
existing = figure(...
'Name', name,...
'NumberTitle','off',...
'Unit', 'normal',...
'MenuBar', 'none',...
'Position', [.1, .1, .7, .7],...
'Visible','off',...
'NextPlot','Add',...
'color', default_color ...
);
editable = [1 1 1];
changable = (default_color + editable) /2;
%create uicontrol buttoms
text_list = ['Source ';...
'Err-Ctr Code';...
'Modulation ';...
'Channel '];
popu_list = ['Rand Int';... % 1
'Read Var';...
'My Own ';... %3
'None ';...
'Hamming ';... %5
'Linear ';...
'Cyclic ';...
'BCH ';...
'R-S ';...
'Convolut';... % 10
'My Own ';...%11
'None ';...
'ASK ';...
'QASK/sq ';...
'QASK/cir';...% 15
'QASK/arb';...
'FSK ';...
'PSK ';...
'MSK ';...
'My Own ';... % 20
'None ';... %21
'AWGN ';...
'Uniform ';...
'Binary ';...
'My Own ';... % 25
'Passband';...
'Baseband'... % 27
];
entry_list = [...
'Sample Freq';...
'Data Length';...
'M-ary Numb ';...
'Seed ';... % 4
'CdWrd Lengt';...
'Msg Length ';...
'Generat Pol';...
'None ';... % 8
'ModSmp Freq';...
'NumbOn Circ';...
'RadiiOn Cir';...
'PhaseOn Cir';... % 12
'Mean ';...
'Var ';...
'Seed ';...
'None ';.... % 16
'Phase Offst';...
'Flt Numerat';...
'Flt Denomin';...
'Carrier Frq';... % 20
];
popu_numb = [0; 3; 11; 20; 25; 27];
line_pos = [.01, 1/5+.01 2/5+.01 4/5-.01, 3/5-.01];
h_axes = axes('position',[0 0 1 1], 'Visible','off', 'next', 'add');
h_plot = plot(0,0,'w-');
for i = 1 : 5
if i == 3
set(h_plot, 'XData', [get(h_plot, 'XData'), (line_pos(i)-.005)+[NaN 0 0 2/5-.03 2/5-.03 0]],...
'YData', [get(h_plot, 'YData'), .44+[NaN 0 .51 .51 0 0]]);
textl(i) = text(line_pos(i), .93, deblank(text_list(i,:)));
elseif i == 5
textl(i) = 0;
else
set(h_plot, 'XData', [get(h_plot, 'XData'), (line_pos(i)-.005)+[NaN 0 0 1/5-.02 1/5-.02 0]],...
'YData', [get(h_plot, 'YData'), .44+[NaN 0 .51 .51 0 0]]);
textl(i) = text(line_pos(i), .93, deblank(text_list(i,:)));
end;
popmu(i) = uicontrol(...
'Style','popupmenu',...
'Unit','norm',...
'Position',[line_pos(i), .86, 1/5-.03, .05],...
'String',popu_list(popu_numb(i)+1 : popu_numb(i+1), :),...
'BackgroundColor', editable,...
'Callback', ['comermn(',num2str(i), ',', num2str(existing) ')']...
);
%for the parameter entries
for j = 1 : 4
temp_indx = (i-1)*4+j;
entr_text(temp_indx) = text(line_pos(i), .82-.1*(j-1),...
entry_list((i-1)*4+j, :));
set(entr_text(temp_indx), 'Visible','off','Fontsize',9);
entr_valu((i-1)*4+j) = uicontrol(...
'Style','edit',...
'Visible', 'off',...
'Unit','norm',...
'BackgroundColor', editable,...
'Position', [line_pos(i), .75-.1*(j-1), 1/5-.03, .05]...
);
end;
end;
set(h_axes,'Xlim',[0, 1], 'Ylim', [0, 1]);
set(entr_valu(1:2), ...
'Visible', 'on',...
'String','100'...
);
set(entr_valu(14 : 15),...
'String','''default'''...
);
set(entr_valu(17),...
'String','0'...
);
set(entr_valu(3),...
'Visible', 'on',...
'String','16'...
);
set(entr_valu(4),...
'Visible', 'on',...
'String','12345'...
);
set(entr_text(1:4),...
'Visible','on'...
);
exec(1) = uicontrol(...
'Style','pushbutton',...
'Unit','norm',...
'Position',[.01, .01, 1/6-.03, .05],...
'String', 'Run',...
'BackGroundColor', editable ...
);
tmp = num2str(entr_valu(2), 20);
set(exec(1), ...
'Callback',...
['set(',num2str(exec(1), 20), ',''Visible'',''on'');',...
'comtmpo;',...
'commod(', num2str(existing), ')']...
);
% 'set(',tmp, ',''UserData'',feval(''get'',' tmp ',''string''));',...
% 'junk = get(', tmp, ', ''string'');'
exec(2) = uicontrol(...
'Style','pushbutton',...
'Unit','norm',...
'Position',[1/6+.01, .01, 1/6-.03, .05],...
'String', 'Close',...
'BackGroundColor', editable, ...
'Callback', ['close(', num2str(existing) ')']...
);
exec(3) = uicontrol(...
'Style','pushbutton',...
'Unit','norm',...
'Position',[2/6+.01, .01, 1/6-.03, .05],...
'String', 'Plot',...
'Enable', 'off',...
'BackGroundColor', editable, ...
'Callback', ['complot(', num2str(existing) ')']...
);
exec(4) = text(3.5/6+.04, .06, 'Curve fit order:');
set(exec(4),'HorizontalA','right',...
'VerticalA','top',...
'FontSize', 9);
exec(5) = uicontrol(...
'Style','edit',...
'Unit','norm',...
'Position',[3.5/6+.04, .01, (1/6-.07)*2/3, .05],...
'BackgroundColor', editable,...
'String', '2'...
);
data_x_b = 1/5-0.07;
tmp = [0 .061 .063 .124 .126 .187 .189 .25]+.103;
%.005
temp = text(data_x_b, tmp(7)+.02, 'Record 1: ');
set(temp, 'Color', [1 1 0], 'Fontsize', 9,...
'HorizontalA','right');
temp = text(data_x_b, tmp(5)+.02, 'Record 2: ');
set(temp, 'Color', [1 0 1], 'Fontsize', 9,...
'HorizontalA','right');
temp = text(data_x_b, tmp(3)+.02, 'Record 3: ');
set(temp, 'Color', [0 1 1], 'Fontsize', 9,...
'HorizontalA','right');
temp = text(data_x_b, tmp(1)+.02, 'Current data: ');
set(temp, 'Color', [1 1 1], 'Fontsize', 9,...
'HorizontalA','right');
for kk = 8:11
patch([data_x_b 1 1 data_x_b data_x_b],...
[0 0 .059 .059 0]+tmp(23-2*kk), 'k');
exec(kk) = text(data_x_b, tmp(23-2*kk)+.02, 1, ' ');
set(exec(kk), 'FontSize', 9);
end;
load_save(1) = uimenu(existing,'Label','File');
uimenu(load_save(1),'Label','Load setup','Interrupt','yes',...
'Call', ['comload(', num2str(existing), ')']);
uimenu(load_save(1),'Label','Save setup','Interrupt','yes',...
'Call', ['comsave(', num2str(existing), ')']);
load_save(1) = uimenu(existing,'Label','Help');
uimenu(load_save(1),'Label','Comm Toolbox','Interrupt','yes',...
'Call', 'hthelp commhelp');
uimenu(load_save(1),'Label','This Example','Interrupt','yes',...
'Call', 'hthelp commfunc');
load_save(4)=plot(0, 0,'w:');
set(load_save(4), 'EraseMode', 'xor', 'Color', .2+[.5 .5 .5]);
bar_color(1) = text(.3, .39, 'Loading setup, please wait...');
set(bar_color(1),'Visible','off','FontSize',9);
bar_color(2) = patch([.01 .0101, .0101 0.01], [0.38 .38 .405 .405], 'r');
set(bar_color(2),...
'EdgeColor', 'none',...
'EraseMode', 'normal'...
);
ex_flag(1) = text(.01, .42, 'Source');
ex_flag(2) = text(1/7, .42, 'Coding');
ex_flag(3) = text(2/7, .42, 'Modulation');
ex_flag(4) = text(3/7, .42, 'Channel');
ex_flag(5) = text(4/7, .42, 'Demodulation');
ex_flag(6) = text(5/7, .42, 'Decoding');
ex_flag(7) = text(6/7, .42, 'Save data');
xd = .96- [18 18 32 32 0 0 50 50 32 NaN 1 1 49 49 NaN 10 12 12 10 NaN ...
20 22 22 20 NaN 30 32 32 30 NaN 40 42 42 40]*0.01*.09;
yd = [95 100 100 95 95 90 90 95 95 NaN 90 0 0 90 NaN 80 75 15 10 NaN ...
80 75 15 10 NaN 80 75 15 10 NaN 80 75 15 10]*0.01*.09 +0.001;
patch([0 0 1 1 0]*.06+.91, [0 1 1 0 0]*.09+.001, 'k')
load_save(2) = plot(xd, yd);
set(load_save(2), 'color', [.8, .4, .2])
load_save(3) = text(.915, .04, 1, 'Trash');
set(load_save(3), 'Fontsize', 9, 'Color', [1 1 1],'Visible','on');
% set(load_save(2),'visible','on','ZData', 0*ones(length(get(load_save(2), 'XData')), 1))
set(load_save(2),'visible','on')
xd = [0 0 1 1 0]*.15+ .73;
yd = [0 1 1 0 0]*.08+.01;
% exec(6) = plot(xd, yd, 'w');
exec(6) = patch(xd, yd, 'k');
% set(exec(6),'visible','on','ZData', 0*ones(length(get(exec(6), 'XData')), 1))
set(exec(6),'visible','on')
exec(7) = text(4.5/6-.02, .04, 1, '>>Workspace');
set(exec(7), 'Fontsize', 9, 'Color', [1 1 1]);
set(ex_flag(1:7), 'Visible','off','Color',[1 1 1], 'Fontsize', 9);
usr_data = [h_axes; h_plot; textl(:); popmu(:); entr_text(:); entr_valu(:); exec(:); load_save(:); bar_color(:); ex_flag(:)];
% 1 1 5 5 20 20 11 4 2 7
set(existing, 'Unit', 'pixels');
tmp = get(existing, 'pos')+[0 0 1 0];
set(existing,...
'UserData', usr_data, ...
'Visible', 'on', ...
'Windowbuttondownfcn', 'combtnd(''main'', 0)',...
'Interruptible', 'yes',...
'Next', 'New' ...
);
tmp_comp = computer;
if findstr(lower(tmp_comp), 'mac')
set(existing,'Windowbuttondownfcn','combtnd2(''mian'',0)');
end;
comload(existing, 1)
drawnow
set(existing,'pos',tmp ,'unit','norm')
else
set(0, 'currentfigure', existing);
end;
drawnow;
%set(bar_color(1), 'Visible', 'on');
%drawnow;
%commod;
if nargin >= 2
set(load_save(1), 'String', fileload);
comload(existing)
elseif nargin == 0
% comload(existing)
end;
%set(bar_color(1), 'Visible', 'off');
% end of commgui
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -