MATLAB Is There a Missing 'rcpulse' Function in Your MATLAB Code?

AI Thread Summary
The MATLAB code for SCFDMA is encountering an error due to the undefined function 'rcpulse', which is intended for generating a raised-cosine pulse shape. The user is prompted to check if the function 'rcpulse.m' is defined in their workspace. The code includes parameters for modulation format, subcarrier mapping, and pulse shaping, but fails at the point where it attempts to call 'rcpulse'. Without this function, the code cannot execute properly, highlighting the importance of ensuring all necessary functions are available. The discussion emphasizes troubleshooting missing function definitions in MATLAB code.
imranisrar
Messages
1
Reaction score
0
here is my MATLAB code of SCFDMA i am getting error at line "psFilter = rcpulse(Ts, Nos,rolloffFactor);" error is Undefined function or method 'rcpulse' for input arguments of type 'double'": function paprSCFDMA()

dataType = 'Q-PSK'; % Modulation format.

totalSubcarriers = 256; % Number of total subcarriers.

numSymbols = 64; % Data block size.

Q = totalSubcarriers/numSymbols; % Bandwidth spreading factor of IFDMA.

Q_tilda =3 ; % Bandwidth spreading factor of DFDMA. Q_tilda < Q.

subcarrierMapping = 'IFDMA'; % Subcarrier mapping scheme.

pulseShaping = 1; % Whether to do pulse shaping or not.

filterType = 'rc'; % Type of pulse shaping filter.

rolloffFactor = 0.5; %Rolloff factor for the raised-cosine filter. %To prevent divide-by-zero, for example, use 0.099999999 instead of 0.1. Fs = 5e6; % System bandwidth.

Ts = 1/Fs; % System sampling rate.

Nos = 4; % Oversampling factor.

if filterType == 'rc' % Raised-cosine filter.

psFilter = rcpulse(Ts, Nos,rolloffFactor);

elseif filterType == 'rr' % Root raised-cosine filter.

psFilter = rrcPulse(Ts, Nos, rolloffFactor);
end

numRuns = 1e4; % Number of iterations.

papr = zeros(1,numRuns); % Initialize the PAPR results.

for n = 1:numRuns,

% Generate random data.
if dataType == 'Q-PSK'
tmp = round(rand(numSymbols,2));
tmp = tmp*2 - 1;
data = (tmp(:,1) + j*tmp(:,2))/sqrt(2);
elseif dataType == '16QAM'
dataSet = [-3+3i -1+3i 1+3i 3+3i ...
-3+i -1+i 1+i 3+i ...
-3-i -1-i 1-i 3-i ...
-3-3i -1-3i 1-3i 3-3i];
dataSet = dataSet / sqrt(mean(abs(dataSet).^2));
tmp = ceil(rand(numSymbols,1)*16);
for k = 1:numSymbols,
if tmp(k) == 0
tmp(k) = 1;
end
data(k) = dataSet(tmp(k));
end
data = data.';
end
% Convert data to frequency domain.
X = fft(data);
% Initialize the subcarriers.
Y = zeros(totalSubcarriers,1);
% Subcarrier mapping.
if subcarrierMapping == 'IFDMA'
Y(1:Q:totalSubcarriers) = X;
elseif subcarrierMapping == 'LFDMA'
Y(1:numSymbols) = X;
elseif subcarrierMapping == 'DFDMA'
Y(1:Q_tilda:Q_tilda*numSymbols) = X;
end
% Convert data back to time domain.
y = ifft(Y);
% Perform pulse shaping.
if pulseShaping == 1
% Up-sample the symbols.
y_oversampled(1:Nos:Nos*totalSubcarriers) = y;
% Perform filtering.
y_result = filter(psFilter, 1, y_oversampled);
else
y_result = y;
end
% Calculate the PAPR.
% papr(n) = 10*log10(max(abs(y_result).^2) / mean(abs(y_result).^2));
end

% Plot CCDF.

[N,X] = hist(papr, 100);

semilogy(X,1-cumsum(N)/max(cumsum(N)),'b')

% Save data.

save paprSCFDMA
 
Physics news on Phys.org
Back
Top