function [xdata, ydata] = computeOneSidedPSD(xdata, ydata, rbw, isPowerSpec, isDecibelUnit)
% This function converts line data to power density
% This file is for internal use only.

%   Copyright 2013 The MathWorks, Inc.
%#codegen

% account for dB units (if any)
% we don't renormalize dBm by 1mW but just leave the power in mW.
if isDecibelUnit
  ydata = exp((log(10)/10)*ydata);
end

% get conversion factor to power density
if isPowerSpec
  ydata = ydata/rbw;
end

% remove negative spectral values
if xdata(1)<0
  ydata(xdata < 0) = [];
  xdata(xdata < 0) = [];
end
