function [path_name,file_name] = findfile(filepath)
namelist = dir( fullfile(filepath,'*.txt'));
k = 1;
file_name_r={{}};
path_name_r={{}};
for i = 1:length(namelist)
if length(namelist) ==1
if not( isfolder( fullfile(filepath,namelist.name) ) )
path_name_r{k} = fullfile(filepath,namelist.name);
file_name_r{k}=namelist.name;
k = k+1;
end
else
if not( isfolder( fullfile(filepath,namelist(i).name) ) )
path_name_r{k} = fullfile(filepath,namelist(i).name);
file_name_r{k}=namelist(i).name;
k = k+1;
end
end
end
path_name = path_name_r;
file_name = file_name_r;
end
[Shell] 纯文本查看复制代码
function [index,data] = filetolist(filepath,format,inx)
fid = fopen(filepath,'r+');
list = textscan(fid,format);
fclose(fid);
index = list{1};
data = list{inx};
end
[Shell] 纯文本查看复制代码
function [str_list] = str_diffsave(strlist,n)
begin = 0;
for i = 1:length(strlist{1})
if not( strncmp(strlist{1},strlist{2},i) )
begin = i;
break;
end
end
str_diff = [];
for i = 1:length(strlist)
str_diff{i} = strlist{i}(begin:end-n);
end
str_list = str_diff;
end
[Shell] 纯文本查看复制代码
function [str] = str_equalsave(strlist)
index_end = 0;
for i = 1:length(strlist{1})
if not( strncmp(strlist{1},strlist{2},i) )
index_end = i;
break;
end
end
str = strlist{1}(13:index_end - 1);
end
[Shell] 纯文本查看复制代码
[pathname,filename] = findfile(pwd);
legend_name = str_diffsave(filename,20);
tiitle_name = str_equalsave(filename);
ylabel_name = {
'snr',
'TotalSims',
'Time',
'Total error',
'Frame err ratio',
'Undetected error',
'ML error',
'Avg # iteration',
'Avg # iteration correct',
'Avg # iteration wrong',
'Avg decode time',
'Avg decode time correct',
'Avg decode time wrong',
'TotalVavNodeTime',
'TotalChkNodeTime',
'TotalChkNodePrjTime',
'TotalLamdaTime',
'TotalPrjExeNum',
'AVg ChkNodePrjTime',
'AVg exact decode time',
'AVg BP decode time'
};
for x = 4:20
text = [];
index =[];
format = '%f %f %s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f';
for i = 1:length(pathname)
[index{i},text{i}] = filetolist(pathname{i},format,x);
end
ind = cell2mat(index)';
data = cell2mat(text)';
figure(x)
semilogy((ind(1,:)),data(1,:),'r-.',(ind(2,:)),data(2,:),'c-+',(ind(3,:)),data(3,:),'k-*','Linewidth',3.0);
set(gca,'fontsize',16);
set(gcf,'color','white');
title([tiitle_name,'576x288'],'Fontsize',16,'Interpreter','none');
xlabel('E_b/N_0(dB)','fontsize',16);
%ylabel('Average Decoding Time(Sec.)','fontsize',16);
ylabel(ylabel_name{x},'fontsize',16);
%ylabel('Avg decode time/s','fontsize',16);
h1=legend(legend_name{1},legend_name{2},legend_name{3});
%h1=legend('C1:FL-LSA','C1:HL-LSA','C1:NS-LSA');
set(h1,'FontSize',12);
grid on;
end