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

📄 errortime.m

📁 802.11仿真源码 对分析RSSI很有用的
💻 M
字号:
function [Errors] = ErrorTime(file_header)
% This function ->
%       ErrorTime: Given the packets file this function finds experiment 4
%       and proceeds to determinet the graph the variance of error rate
%       over time in 1000 group packets. 
%           The 1000 grouping can easily be changed to any other variable.
filename = [file_header];

fid = fopen(filename,'r');

tline = fgets(fid);

z = 0;
o = 0;
current = 1;
Bursts = zeros(2000,1);
count = 0;
room_back = 0;
mp_back = 0;
line_counter = 0;

timeslot = 1;
packet = 0;

% Finds experiment 4 within packets file
while(1)
   tline = fgets(fid);
   room = sscanf(tline,'%f');  % extract room number 
   mp = Extract(tline, 1);      % extract MP
   
   if((room == room_back) && (mp == mp_back))
       break;
   end
   
   room_back = room;
   mp_back = mp;
   line_counter = line_counter + 1;
end

% Rewind over missed line so to incorporate all experiment 4 data. 
frewind(fid)
i = 1;
while(i <= line_counter)
    tline = fgets(fid);
    i = i + 1;
end

while(~feof(fid))
    tline = fgets(fid);
    
    tline = tline(9:length(tline));
    
    for (i=1:length(tline))
        packet = packet + 1;
        if (rem(packet,1000)==0)
            Error(timeslot) = z/(o+z)*100;
            o = 0;
            z = 0;
            timeslot = (timeslot + 1);  %increment counter
        end
        if (tline(i)=='1')
            o = o + 1;
            if (current == 0)
                Bursts(count) = Bursts(count) + 1;
                count = 0;
                current = 1;
            end
        else
            z = z + 1;
            if (current == 0)
                count = count + 1;
            else
                current = 0;
                count = 1;
            end
        end
    end
end
fclose(fid);


figure; plot(Error); title ('Time Variance of Error rate'); xlabel('Packet Group (1000 packets/group)'); ylabel('Error Rate (%)');
disp('Statistics for Errors: (the mean error rate and standard deviation error rate)')

⌨️ 快捷键说明

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