Matlab Script in Python to get call data
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call Python from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!