Home > Back-end >  I am trying to convert these 2 lines of Matlab code into python. first line is fine but how could I
I am trying to convert these 2 lines of Matlab code into python. first line is fine but how could I

Time:10-02

This is my MATLAB code. Note that T_cqi=28

gamma_real=reshape(gamma_dB(:,(length(CQI_init) 1):end),[1,length(CQI_test)*T_cqi]); 
gamma_real=gamma_real(1:(end-(T_cqi-1)));

This part in matlab is (length(CQI_init) 1=180 in python it works with 179

I convert it like this:

gamma_real=np.reshape(gamma_dB[:,179:],[1,(CQI_test.size)*T_cqi])

which is fine but I am not able to do the second line? how could i do this? what should I write for end key word?

CodePudding user response:

In python, no index for the second indexer automatically refers to the end of the array, so try:

gamma_real=gamma_real[: -T_cqi]

(No index for the first index refers to the first index which is 0 in Python)

  • Related