clear all; close all;
a = logspace(-1,3);
p = zeros(1,50);
for i = 1:length(a)
S(i) = calcS(a(i),p(i));
end
f = figure;
semilogx(a,S); hold on;
title('SAW-ARQ performance');
xlabel({'a','','','','',''});
ylabel('normalized throughput'); grid on;
sliderControl(f);
function a = calcA(d,v,L,R)
a = (d/v)/(L/R);
end
function S = calcS(a,p)
S = (1-p)/(1+2*a);
end
function [] = sliderControl(f)
guidata(f,struct('d',1000,'dr',64000,'pdu',1000));
sliderDistance = uicontrol('Parent',f,'Style','slider','Position',[160,60,360,23],...
'String','distance','value',1000,'min',0,'max',10e6);
uicontrol('Parent',f,'Style','text','Position',[10,56,140,23],...
'String','Distance [0m...1000km]','BackgroundColor',f.Color);
addlistener(sliderDistance,'ContinuousValueChange',@updateGraph);
sliderDataRate = uicontrol('Parent',f,'Style','slider','Position',[160,35,360,23],...
'String','datarate','value',64000,'min',0,'max',10e8);
uicontrol('Parent',f,'Style','text','Position',[10,31,140,23],...
'String','Data rate [0bit/s...1Gbit/s]','BackgroundColor',f.Color);
addlistener(sliderDataRate,'ContinuousValueChange',@updateGraph);
sliderPDU = uicontrol('Parent',f,'Style','slider','Position',[160,10,360,23],...
'String','pdu','value',1000,'min',0,'max',1500);
uicontrol('Parent',f,'Style','text','Position',[10,6,140,23],...
'String','PDU length [0bit...1500bit]','BackgroundColor',f.Color);
addlistener(sliderPDU,'ContinuousValueChange',@updateGraph);
end
function [] = updateGraph(varargin)
hObj = varargin{1};
data = guidata(hObj);
if strcmp(get(hObj,'String'),'distance')
data.d = hObj.Value;
guidata(hObj,data);
elseif strcmp(get(hObj,'String'),'datarate')
data.dr = hObj.Value;
guidata(hObj,data);
else
data.pdu = hObj.Value;
guidata(hObj,data);
end
a = logspace(-1,3);
tempA = calcA(data.d,3e8,data.pdu,data.dr);
tempS = calcS(tempA,0.00);
if tempA > a(1) && tempA < a(length(a))
plot(tempA,tempS,'or','MarkerSize',5,'MarkerFaceColor','r');
pause(.5);
end
end