Matlab Script in Python to get call data

1 次查看(过去 30 天)
AA
AA 2021-7-18
评论: AA 2021-7-18
Dear All,
my data file is like this in .mat: data_input_file . First colum: year; Second colum: days; Third colum: data
Initially, I wrote a code in Matab to pick the data (CF) in a sliding window fashion (-5, +5) days and then stacks the values in other variable . MAtlab script is
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 > lengday; k = lengday; end
if k <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
I required to transform my script to python. However, the last line of script is not working: Here is my attempted, these variables are defined in below, if i dont use the [K] , it will work but with [k], it gives the error.
zz =mat['CFdata'][k]['NCF'][0:lastday,1]/max([mat['CFdata']['NCF'][0:lastday,1]])/[abs(j)+1]
Function of the above line: This line select a specific day, then take the data of plus/mins 5 days (around the selected day). Afterward, stack the data of all 11 days.
Parameteres used in the above line is defined defined as below:
parameteres used here difinied as
CFdata=mat.get('CFdata')
time=mat.get('CFtime')
day=CFdata["day"]
year=CFdata["year"]
NCF=CFdata["NCF"]
firstday=1
lengday=len(day[0])
  2 个评论
Yongjian Feng
Yongjian Feng 2021-7-18
So this is more like a question about python?
AA
AA 2021-7-18
yeah, I want to convert this matlab script in python.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Call Python from MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by