📄 zulkaif.m
字号:
while(1)
clc
close all
clear all
t = 0:0.00001:0.001;
Fc1 = 1000;
Fc2 = 2000;
Fc3 = 3000;
Fc4 = 4000;
Fc5 = 5000;
Fs = 12000;
y1 = 0; y2 = 0; y3 = 0; y4 = 0; y5 = 0; Y = 0; y = 0;
x1 = cos(2*pi*1000*t);
x2 = cos(2*pi*2000*t);
x3 = cos(2*pi*3000*t);
x4 = cos(2*pi*4000*t);
x5 = cos(2*pi*5000*t);
in_p = input('\nDo you want to enter first primary user Y/N: ','s');
if(in_p == 'Y' | in_p == 'y')
y1 = ammod(x1,Fc1,Fs);
end
in_p = input('Do you want to enter second primary user Y/N: ','s');
if(in_p == 'Y' | in_p == 'y')
y2 = ammod(x2,Fc2,Fs);
end
in_p = input('Do you want to enter third primary user Y/N: ','s');
if(in_p == 'Y' | in_p == 'y')
y3 = ammod(x1,Fc3,Fs);
end
in_p = input('Do you want to enter fourth primary user Y/N: ','s');
if(in_p == 'Y' | in_p == 'y')
y4 = ammod(x1,Fc4,Fs);
end
in_p = input('Do you want to enter fifth primary user Y/N: ','s');
if(in_p == 'Y' | in_p == 'y')
y5 = ammod(x1,Fc5,Fs);
end
y = y1 + y2 + y3 + y4 + y5;
if( y == 0)
disp('All bands are available');
break;
else
Pxx = periodogram(y);
Hpsd = dspdata.psd(Pxx,'Fs',Fs);
plot(Hpsd);
chek1 = Pxx(25).*10000;
chek2 = Pxx(49).*10000;
chek3 = Pxx(62).*10000;
chek4 = Pxx(89).*10000;
chek5 = Pxx(105).*10000;
if(chek1 < 8000)
disp('User 1 is not present.');
end
if(chek2 < 8000)
disp('User 2 is not present.');
end
if(chek3 < 8000)
disp('User 3 is not present.');
end
if(chek4 < 8000)
disp('User 4 is not present.');
end
if(chek5 < 8000)
disp('User 5 is not present.');
end
end
% Adding noise effect into the signal
noise_in = input('Do you want to add noise effect? [Y/N]: ','s');
if(noise_in == 'Y' | noise_in == 'y')
figure
Y = awgn(y,0.01);
Pxx1 = periodogram(Y);
Hpsd = dspdata.psd(Pxx1,'Fs',Fs);
plot(Hpsd);
chek1 = Pxx1(25).*10000;
chek2 = Pxx1(49).*10000;
chek3 = Pxx1(62).*10000;
chek4 = Pxx1(89).*10000;
chek5 = Pxx1(105).*10000;
if(chek1 < 8000)
disp('User 1 is not present.');
end
if(chek2 < 8000)
disp('User 2 is not present.');
end
if(chek3 < 8000)
disp('User 3 is not present.');
end
if(chek4 < 8000)
disp('User 4 is not present.');
end
if(chek5 < 8000)
disp('User 5 is not present.');
end
else
disp('Rerun the program again....');
break;
end
%Adding Attenuation to the bands
temp = input('Do you want to attenuate the signals? [Y/N]: ','s');
if(temp == 'Y' | temp == 'y')
aF = input('Enter the percentage to attenuate the signal: ');
figure
tem = aF/100;
tm = 1-tem;
Yf = y.*tm;
Pxx2 = periodogram(Yf);
Hpsd = dspdata.psd(Pxx2,'Fs',Fs);
plot(Yf);
chek1 = Pxx2(25).*10000;
chek2 = Pxx2(49).*10000;
chek3 = Pxx2(62).*10000;
chek4 = Pxx2(89).*10000;
chek5 = Pxx2(105).*10000;
if(chek1 < 8000)
disp('User 1 is not present.');
end
if(chek2 < 8000)
disp('User 2 is not present.');
end
if(chek3 < 8000)
disp('User 3 is not present.');
end
if(chek4 < 8000)
disp('User 4 is not present.');
end
if(chek5 < 8000)
disp('User 5 is not present.');
end
else
disp('Rerun the program again....');
end
%if rerun the program
temp = input('Do you want to re-run the program? [Y/N]: ','s');
if(temp == 'Y' | temp == 'y')
disp('\n\nEnter the users again.\n\n');
else
break;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -