You are on page 1of 2

Weve taken 5 carrier frequencies Fc1 = 1000, Fc2 = 2000, Fc3 = 3000, Fc4=4000 & Fc5 = 5000 keeping

the user message/ ata signa! frequenc" as 1000# x = cos(2*pi*1000*t)//every users base band data signal $nce user 1s ata arrive, it is m% u!ate at the first carrier Fc1, simi!ar!" as the 2 n users ata arrives, it is m% u!ate at the 2n carrier Fc2, s% %n ti!! fifth user is assigne the Fc5 &an # 'f an" users ata is n%t present his frequenc" &an remains empt" (hich is ca!!e a )pectra! *%!e#
in_p = input('\n o you !ant to enter "irst pri#ary user $/%& i"(in_p == '$' ) in_p == 'y') y1 = a##od(x'*c1'*s)( end : : : in_p = input(' o you !ant to enter "i"t+ pri#ary user $/%& i"(in_p == '$' ) in_p == 'y') y, = a##od(x'*c,'*s)( end '''s')(

'''s')(

$nce a!! the assignment is c%mp!ete (e a ana!"+e f%r empt" s!%ts as the channe!#
y = y1 - y2 - y. - y/ - y,(

a!! the signa!s t% create a carrier signa! (hich (i!! &e

Now well estimate the power spectral density of our carrier signal using the periodogram(); function and the values are stored in an array Pxx. Pxx is the distribution of power per unit fre uency. !his value is then stored in a dsp data ob"ect and then plotted.
0xx = periodogra#(y)( 1psd = dspdata2psd(0xx''*s''*s)( plot(1psd)(
//*s = ,)-,./.#0,./.$1234/56###7 returns a ,)- ata %&8ect, *s, %f t"pe specifie c%mm%n ata %&8ects are //msspectrum 9 :ean9square )pectrum 6:))7 ata %&8ect //ps 9 -%(er )pectra! ,ensit" 6-),7 ata %&8ect //pseu %spectrum 9 -seu % )pectrum ata %&8ect &" ,./.$1234/# )%me

# obtained a five points for all users in the array Pxx which multiplied by $%%%% should be above &%%% if theres no spectral hole. ''this "ust an observation which is wor(ing so far) the technical aspects will b addressed later in the presentation.
c+e31 = 0xx(2,)2*10000( c+e32 = 0xx(/4)2*10000( c+e3. = 0xx(42)2*10000( c+e3/ = 0xx(56)2*10000( c+e3, = 0xx(10,)2*10000(

Now if theres a new user entering the channel) well chec( the array Pxx) at certain location and assign user the first spectral gap as coded below

i"(c+e31 7 5000) disp('8ssigned to 9ser 1 as it !as not present2')( y1 = a##od(x1'*c1'*s)( elsei" (c+e32 7 5000) disp('8ssigned to 9ser 2 as it !as not present2')( y2 = a##od(x1'*c2'*s)( : : : elsei"(c+e3, 7 5000) disp('8ssigned to 9ser , as it !as not present2')( y, = a##od(x1'*c,'*s)( else disp('all user slots in use2 try again later'')(

:+en !e +ave t+e slot e#ptying algorit+# !+ic+ !ill e#pty t+e already occupied bands by as3ing user to c+oose a slot and executing t+e "ollo!ing code
in_p = input('\n o you !ant to e#pty "irst users slot $/%& i"(in_p == '$' ) in_p == 'y') y1 = 0( end : : : in_p = input(' o you !ant to e#pty "i"t+ users band $/%& i"(in_p == '$' ) in_p == 'y') y, = 0( end y = y1 - y2 - y. - y/ - y,( '''s')(

'''s')(

8nd t+en !e repeat t+e above plotting procedure t+at !as done a"ter t+e assign#ents2 :o add noise to our signal ;ve used t+e si#pler a!gn()( "unction2
noise_in = input(' o you !ant to add noise e""ect< =$/%>& i"(noise_in == '$' ) noise_in == 'y') "igure $ = a!gn(y'0201)( 0xx1 = periodogra#($)( 1psd = dspdata2psd(0xx1''*s''*s)( plot(1psd)( '''s')(

/% attenuate %ur signa! the s"stem asks f%r the percentage %f attenuati%n require f%!!%(e &" the p!%t %f the attenuate carrier signa!# /he percentage ivi e &" hun re is su&tracte fr%m 1 an the remaining num&er is mu!tip!ie (ith the signa!#
te#p = input(' o you !ant to attenuate t+e signals< =$/%>& '''s')( i"(te#p == '$' ) te#p == 'y') a* = input('?nter t+e percentage to attenuate t+e signal& ')( "igure te# = a*/100( t# = 1@te#( $" = y2*t#( plot($")(

You might also like