title: How to modify Matlab Script in python to call data
body: <p>my data file is like this in .mat:
  [data_input_file][1] .
  First column: year; Second column: days; Third column: data</p>
  <p>Initially, I wrote a code in Matlab to pick the data (CF) in a sliding window fashion (-5, +5) days and then stacks the values in variables. Matlab script is</p>
  <pre><code>bpn=1
   for i = 1:lengday % for i in range(lengday)
          zz2 = 0;
          zz=0;
          for j = -5:5  % days to be stacked
              k=i+j;
              if k &gt; lengday; k = lengday; end
              if k &lt;1; k = 1; end
              zz =CFdata(k).NCF(1:end,bpn)'./max(CFdata(k).NCF(1:end,bpn))/(abs(j)+1);
              zz2= zz2+zz;
    end
  </code></pre>
  <p>I was required to transform my script to python. However, the last line of the script is not working: Here is my attempted, these variables are defined in below</p>
  <pre><code>mat=scipy.io.loadmat('hydhyd_1.mat') #read the mat file
  
  
  day=CFdata[&quot;day&quot;]
  firstday=1
  lastday=len(day[0])
  total_day=np.arange(firstday,lastday)
  
  for i in range(lastday):
      zz2 = 0;
      zz=0;
      for j in range(-5,5):
          k=i+j;
         # print(k)
          if k &gt; lastday:
              k = lastday
          if k &lt;1:
              k = 1
    #  print(k)
  zz2=0
  #zz =mat['CFdata'][k]['NCF'][0:lastday,1]/max([mat['CFdata']['NCF'][0:lastday,1]])/[abs(j)+1]; #this is not working
  zz =CFdata['NCF'][0,0:9]/max([mat['CFdata']['NCF'][0:lastday,1]])/[abs(j)+1];
  zz2= zz2+zz
  plt.plot(zz[0])
  </code></pre>
  <p><strong>Function of the above line:</strong>
  This line selects a specific day, then takes the data of plus/minus 5 days (around the selected day). Afterward, stack the data of all 11 days.
  [1]: <a href="https://i.stack.imgur.com/e3kKX.png" rel="nofollow noreferrer">https://i.stack.imgur.com/e3kKX.png</a></p>