MATLAB code for spectrum sensing for cognitive radio

if true
% code
endthis is my matlab code but it did not work for me even if i download it from internet. when i try to run in matlab it says character values loop is resizing continuously so it tell me to fix it but i did not know how to fix it.please help me! THANK YOU in advance!
close all;
clear all;
%
% PARAMETERS
%
freq = 200; %operating frequency
Fs = 20*f; %sampling frequency
L=100; % Number of samples per symbol period
Ts = 1/Fs; % Sampling period
T = Ts:Ts:1/f;
alpha=0.5; % Roll-off factor for the (square-root) raised cosine filters
N=8*L; % N+1 is the length of the square-root raised-cosine filter.
sigma_v=0; % Standard deviation of channel noise
h=1; % Channel impulse response
%
%SOURCE: Take input data from user for transmission
%
pt_dt = input('Data you want to send:','s');
R = isempty(pt_dt);
if R == 1
pt_dt = 'Waleed Ejaz';
else
pt_dt = pt_dt;
end
display(pt_dt);
RR = double(pt_dt);
bb = 1;
Rp = dec2bin(RR,7);
[TA TC] = size(Rp);
for ll = 1:1:TA
for lg = 1:1:TC
msg(bb) = Rp(ll,lg);
bb = bb + 1;
end
end
rt = 1; ht = 1;
for ls = 1:1:TA
for ll = 1:2:(TC-1)
Inp_msg(rt,(ht:ht+1)) = Rp(ls,(ll:ll+1));
rt = rt + 1;
end
end
%
% Transmit Filter
%
pT=f_sr_cos_p(N,L,alpha); % Transmit filter:
xT=conv(f_expander(msg,L),pT); % Transmit signal
%
% Modulation
%
display('Select Type of Modulation');
display('1. BPSK');
display('2. QPSK');
Mod_Type = input('Plz Enter the Type of Modulation:','s');
Carrier = [];
%
% BPSK Modulation
%
if (Mod_Type=='1')
display('Binary PSK');
for ii = 1:1:length(T)
car1(ii) = sin((2*pi*freq*T(ii))); %CARRIER TO BE TRANSMITTED
end
for ii = 1:1:length(xT)
if xT(ii) == '0'
car = -1*car1;
else
car = 1*car1;
end
Carrier = [Carrier car];
end
%
% QPSK Modulation
%
else if(Mod_Type=='2')
for ii = 1:1:length(T)
car1(ii) = sin((2*pi*freq*T(ii))+360); %CARRIER TO BE TRANSMITTED
car2(ii) = sin((2*pi*freq*T(ii))+90); %CARRIER TO BE TRANSMITTED
car3(ii) = sin((2*pi*freq*T(ii))+180); %CARRIER TO BE TRANSMITTED
car4(ii) = sin((2*pi*freq*T(ii))+270); %CARRIER TO BE TRANSMITTED
end
for ii = 1:1:length(Inp_msg)
if Inp_msg(ii) == '00'
car = car1;
else if Inp_msg(ii) == '01'
car = car2;
else if Inp_msg(ii) == '10'
car = car3;
else if Inp_msg(ii) == '11'
car = car4;
end
end
end
end
Carrier = [Carrier car];
end
if true
% code
end end % end of if
end %end of else if
%
if true
% code
end
% CHANNEL
%
xR=conv(h,Carrier);
if true
% code
end
xR=xR+sigma_v*randn(size(xR)); % Received signal

Answers (0)

Categories

Asked:

on 7 May 2017

Edited:

on 7 May 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!