If I understand correctly, you want to have a MATLAB script that resembles the behavior of 'cpgram' in R.
A possible answer to your question is to use the periodogram function that MATLAB provides, and then take the cumulative sum of the power.
You can find more information on the periodogram function in the following link:
I will use an example from that documentation page to illustrate my suggestion.
The periodogram can be calculated using the following:
fs = 1000;
t = 0:0.001:1-0.001;
x = cos(2*pi*100*t)+sin(2*pi*150*t)+randn(size(t));
[pxx,f,pxxc] = periodogram(x,rectwin(length(x)),length(x),fs,...
'ConfidenceLevel', 0.95);
figure()
plot(f,10*log10(pxx))
hold on
plot(f,10*log10(pxxc),'r-.')
hold off
xlim([85 175])
xlabel('Hz')
ylabel('dB')
title('Periodogram with 95%-Confidence Bounds')
and the outcome of that will look something like this:
From the variables calculated by the periodogram function, you can use the pxx variable to calculate the cumulative sum of the power.
You can do this with the following code:
cpxx = cumsum(pxx)./sum(pxx);
figure()
plot(f,cpxx)
hold on
plot(f,f./max(f)+0.05,'r--')
plot(f+0.05*max(f),f./max(f),'r--')
axis([0 500 0 1])
xlabel('Frequency(Hz)')
ylabel('Cumulative periodogram')
hold off
This code will yield the following result: