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

📄 handof.m

📁 steganography program
💻 M
字号:
clear all;
clc;
close all;
pt=1;
gt=1;
gr=1;
prth=10^(-5);            % threshold power level=0.00001 units

tim=input('enter the no. of instants:');
t=1:tim;                 % for five instants

%------for cell 1 ------

freq0=100e6;             % operating frequency= 100 MHZ
lmbd0=3e8/freq0;         %oerating wavelength

d0=40.0;                 %radius=40 units
p0=pt*gt*gr*(lmbd0/(4*pi*d0))^2;   %antenna gain
for i=1:tim
    users0(i)=poissrnd(30);
    for j=1:users0(i)
        vlc0(i,j)=unifrnd(0.01,20,1,1);
    end
end
mxuser=max(users0);
flag0(tim,mxuser)=0;
for i=1:tim
    for j=1:mxuser
        for k=1:tim
            dv0=vlc0(i,j)*k;   %calculate distance at each given instance
            pr0(i,j,k)=p0*((dv0/d0)^(-4)); % received power by the base stn.
            if(pr0(i,j,k)<prth)
                flag0(i,j)=k;   % set the flag at given instant of rec power is
                                % less than threshold power
                break;
            end
        end
    end
    hoff0(1,tim)=0;
    for i =1:tim
        for j=1:mxuser
            for k=1:tim
                if(flag0(i,j)==k)
                    hoff0(k)=hoff0(k)+1;
                end 
            end
        end
    end
    figure(1);
    stem(t,hoff0,'b');         %plot no. of users for hand-off vs.each instant
    title('no. of hand-off users vs.time instants from cell no.1to cell no.2');
    
    %-----for cell 2------
    
    freq1=150e6;      % operating frequency=150 MHZ
    lmbd1=3e8/freq1;  % operating wavelength
    
    d1=45.0;          %radius=45 units
    p1=pt*gt*gr*(lmbd1/(4*pi*d1))^2; % antenna gain
    for i=1:tim
        users1(i)=poissrnd(35);
        for j=1:users1(i)
            vlc1(i,j)=unifrnd(0.01,20,1,1);
        end
    end
    mxuser1=max(users1);
    flag1(tim,mxuser)=0;
   for i=1:tim
      for j=1:mxuser1
        for k=1:tim
            dv1=vlc1(i,j)*k;  %calculate distance at each give instance
            pr1(i,j,k)=p1*((dv1/d1)^(-4)); % received power by base stn.
            if(pr1(i,j,k)<prth)
                flag1(i,j)=k;  %set the flag at given instant if rec power is
                               % less than threshold power
                break;
            end
        end
    end
end
hoff1(1,tim)=0;
    for i =1:tim
        for j=1:mxuser1
            for k=1:tim
                if(flag1(i,j)==k)
                    hoff1(k)=hoff1(k)+1;
                end 
            end
        end
    end
    figure(3);
    stem(t,hoff1,'b');   % plot no. of users for hand-off vs. each instant
    title('no. of hand-off users vs. time instants from cell no.2 to cell no.1');
    
    %--------blocking---------
    
    caph0=30;        % capacity of 1st cell=30
    capv0=10;
    caph1=30;        % capacity of 2nd cell=31
    capv1=10;
    for i=1:tim
        diff0(i)=hoff1(i)-hoff0(i);
        if(diff0(i)>capv0)
            newcaph0(i)=caph0-(diff0(i)-capv0);
            if(users0(i)>newcaph0(i));
                blck0(i)=users0(i)-newcaph0(i);
            else
                blck0(i)=0;
            end
        else
            if(users0(i)>caph0)
                blck0(i)=users0(i)-caph0;
            else
                blck0(i)=0;
            end
        end
    end
    figure(2);
    stem(t,blck0,'r');      % plot no. of blocked users vs. each instant for cell 1
    title('no. of blocked users vs. time instants in cell no.1');
    for i=1:tim 
    diff1(i)=hoff0(i)-hoff1(i);
        if(diff1(i)>capv1)
            newcaph1(i)=caph1-(diff1(i)-capv1);
            if(users1(i)>newcaph1(i))
                blck1(i)=users1(i)-newcaph1(i);
            else
                blck1(i)=0;
            end
        else
            if(users1(i)>caph1)
                blck1(i)=users1(i)-caph1;
            else
                blck1(i)=0;
            end
        end
    end
end
  
    figure(4);
    stem(t,blck1,'r');   % plot no. of blocked users vs. each instant for cell 2
    title('no. of blocked users vs. time instants in cell no.2');
    fprintf('\n');
    disp('users0:');
    disp(users0);
    disp('hoff1:');
    disp(hoff1);
    disp('hoff0:');
    disp(hoff0);
    disp('blck0:');
    disp(blck0);
    
    fprintf('\n');
    disp('users1:');
    disp(users1);
    disp('hoff0:');
    disp(hoff0);
    disp('hoff1:');
    disp(hoff1);
    disp('blck1:');
    disp(blck1);
    

⌨️ 快捷键说明

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