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

In summary, the conversation is about a MATLAB code for SCFDMA with a function called rcpulse. The code is generating an error at a specific line and the error is for an undefined function or method. The code includes different parameters such as data type, total subcarriers, data block size, bandwidth spreading factors, subcarrier mapping scheme, pulse shaping, filter type, system bandwidth, oversampling factor, and number of iterations. The code also involves generating random data, converting it to the frequency domain, subcarrier mapping, converting it back to the time domain, and performing pulse shaping. The main purpose of the code is to calculate the PAPR (peak-to-average power ratio) and plot the CCDF (complementary
  • #1
imranisrar
1
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
  • #2


do you have a function defined as rcpulse.m?
 

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

What does the error "Undefined function or method 'rcpulse' for input arguments of type" mean in Matlab?

This error means that the function or method "rcpulse" is not recognized by Matlab. This could be due to a few reasons, such as the function not being included in the current working directory or the function not being defined properly.

How can I fix the "Undefined function or method 'rcpulse' for input arguments of type" error in Matlab?

To fix this error, you can try a few things. First, make sure that the function "rcpulse" is included in the current working directory. If it is not, you can add it by using the "addpath" function in Matlab. Additionally, you can check if the function is defined properly and if all the necessary input arguments are included.

Why am I getting the error "Undefined function or method 'rcpulse' for input arguments of type" when I know the function exists in my current working directory?

This could be due to a few reasons. First, make sure that the function name is spelled correctly and that the function is saved with a .m extension. Additionally, check if the function is defined properly and if all the input arguments are included. If the problem persists, try restarting Matlab or clearing the workspace.

Can a missing input argument cause the "Undefined function or method 'rcpulse' for input arguments of type" error in Matlab?

Yes, a missing input argument can cause this error. Make sure that all the necessary input arguments are included when calling the function. If an input argument is missing, Matlab will not be able to execute the function and will return this error.

Is there a way to prevent the "Undefined function or method 'rcpulse' for input arguments of type" error from occurring in Matlab?

Yes, there are a few ways to prevent this error from occurring. First, make sure to properly define and save the function in the current working directory. You can also use the "which" function in Matlab to check if the function is recognized. Additionally, make sure to include all the necessary input arguments when calling the function.

Similar threads

Replies
1
Views
2K
Replies
8
Views
2K
Replies
1
Views
3K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
4
Views
3K
Replies
1
Views
9K
Back
Top