clear all clc % Write display messages to a text file diary spectrum_availability.txt % Choose total amount of available spectrum in MHz tot_spec = input(' Enter the total available spectrum for the Primary System in MHz, Default: 20 '); if isempty(tot_spec) tot_spec = 20; end % Time of the Day time_day = input(' Indicate time of the day using flag (1 for 11pm, 2 for 3am, 3 for 7am, 4 for 11am, 5 for 3pm, 6 for 7pm), Default: 1 '); if isempty(time_day) time_day = 1; end PercentTraffic_CellsMapping = cell(6,1); % a structure of 6 matrices, one matrix for each of the six supported times of the day % Col 1 and Col 2 indicate traffic range and the Col 3 indicate how many % cells have traffic in that range PercentTraffic_CellsMapping{1} = [0 5 9;5 10 2;10 15 2;15 20 1;20 25 1;25 40 2;40 100 1]; PercentTraffic_CellsMapping{2} = [0 5 13;5 10 1;10 30 3;30 100 1]; PercentTraffic_CellsMapping{3} = [0 5 15;5 10 1;10 20 2;20 100 1]; PercentTraffic_CellsMapping{4} = [0 5 12;5 10 1;10 15 1;15 30 3;30 100 1]; PercentTraffic_CellsMapping{5} = [0 5 11;5 10 2;10 15 1;15 20 1;20 35 2;35 100 1]; PercentTraffic_CellsMapping{6} = [0 5 10;5 10 2;10 15 1;15 25 2;25 40 2;40 100 1]; CentralCell_Loading = [98 65 46 71 72 84]; CellIndx = 1; % Traffic of central cell CellTrafficDemand(CellIndx,1) = CentralCell_Loading(time_day); % Applying plus minus 10% random variation CellTrafficDemand(CellIndx,1) = CellTrafficDemand(CellIndx,1) + randint(1,1,[-10 10]); if CellTrafficDemand(CellIndx,1) > 100 CellTrafficDemand(CellIndx,1) = 100; end % Spectrum demand CellSpectrumDemand(CellIndx,2) = (CellTrafficDemand(CellIndx,1)/100) * tot_spec; CellSpectrumDemand(CellIndx,1) = int8(CellIndx); % To get the % traffic and corresponding spectrum demand of rest of 18 cells w.r.t the central cell [Row Col] = size(PercentTraffic_CellsMapping{time_day}); for i = Row:-1:1 NoOfCells(i) = PercentTraffic_CellsMapping{time_day}(i,3); for j = 1:NoOfCells(i) CellIndx = CellIndx + 1; CellTrafficDemand(CellIndx,1) = randint(1,1,[PercentTraffic_CellsMapping{time_day}(i,1) PercentTraffic_CellsMapping{time_day}(i,2)]); CellSpectrumDemand(CellIndx,2) = (CellTrafficDemand(CellIndx,1)/100) * CellSpectrumDemand(1,2); CellSpectrumDemand(CellIndx,1) = CellIndx; end end fprintf('\n Spectrum Demand of Primary System in each of 19 cells: \n\n'); fprintf(' Cell ID Spectral Demand in MHz: \n '); for i=1:19 fprintf('%2i %5.1f \n ', CellSpectrumDemand(i,1), CellSpectrumDemand(i,2)); end Spec4SecondaryUse_19Cells = tot_spec - CellSpectrumDemand(1,2); Spec4SecondaryUse_2ndTier = CellSpectrumDemand(1,2) - CellSpectrumDemand(2,2); fprintf('\n Chunk of Spectrum made available by Primary System for Secondary use over all the 19 cells area : %5.1f MHz \n', Spec4SecondaryUse_19Cells); fprintf(' Chunk of Spectrum made available by Primary System for Secondary use in only Tier-2 cells area : %5.1f MHz \n\n', Spec4SecondaryUse_2ndTier);