I'm trying to convert a code written in MATLAB to python script. I don't much of prior knowledge in MATLAB, so I'm unable to figure out what this code is doing and how to convert it to python.
sumint=[];
for k=1:1:length(d)-(tint-2)
sumint=[sumint;sum(d(k:k+(tint-2)))]
end
I've tried some combinations of function but the output is not matching
My code
sum_disp = []
for i in range(0, len(disp) - (points_grouped - 2)):
sum_disp.append(sum(disp[i:(i + (points_grouped - 1))]))
sum_disp = np.array(sum_disp)
Can someone please tell me how to covert that piece of code from MATLAB to python
d = disp
tint = points_grouped
sumint = sum_disp
d = [0.02801167 0.03669624 0.0272492 0.0208854 0.0082905 0.01288594
0.01017967 0.01465445 0.01436482 0.05004975 0.0062021 0.02299043
0.02368145 0.006786 0.02977529 0.01532477 0.02310713 0.02113559
0.03423545 0.01603583 0.03599799 0.01562202 0.05216167 0.04165677
0.01075509 0.01963266 0.03076811 0.02368203 0.04459419 0.01227608
0.01554692 0.01537159 0.01947022 0.01487557 0.00755353 0.02223923
0.03342209 0.04716421 0.02321706 0.03620767 0.01531807 0.02143145
0.07581067 0.09864071 0.06802934 0.08344471 0.04110631 0.02693593
0.01805178 0.02831497 0.02184237 0.02761051 0.03136386 0.02887697
0.03444354 0.0232088 0.04235497 0.03862241 0.0228297 0.03749918
0.03118549 0.01920405 0.04887996 0.03679627 0.03127032 0.03119164
0.00888661 0.01037151 0.03510487 0.09559838 0.0715161 0.06366703
0.04879124 0.05652408 0.08160136 0.0707258 0.10876558 0.06095913
0.06669257 0.14134084 0.11763063 0.08965415 0.06882186 0.11428816
0.09198447 0.04850028 0.03025621 0.02059732 0.02590883 0.00680715
0.01868523 0.01118559 0.01455745 0.04500167 0.01250587 0.02199164
0.0175176 0.02161969 0.00989601 0.07096723 0.05321957 0.07031943
0.06077753 0.0315616 0.07922844 0.03241386 0.04955126 0.04118749
0.07775704 0.03544656 0.02747782 0.01317484 0.0086493 0.0066854
0.03952626 0.04835286 0.04847035 0.04397535 0.0723641 0.12843771
0.06867013 0.51434501]
MATLAB output
sumint =
0.0920
0.0848
0.0564
0.0421
0.0314
0.0377
0.0392
0.0791
0.0706
0.0792
0.0529
0.0535
0.0602
0.0519
0.0682
0.0596
0.0785
0.0714
0.0863
0.0677
0.1038
0.1094
0.1046
0.0720
0.0612
0.0741
0.0990
0.0806
0.0724
0.0432
0.0504
0.0497
0.0419
0.0447
0.0632
0.1028
0.1038
0.1066
0.0747
0.0730
0.1126
0.1959
0.2425
0.2501
0.1926
0.1515
0.0861
0.0733
0.0682
0.0778
0.0808
0.0879
0.0947
0.0865
0.1000
0.1042
0.1038
0.0990
0.0915
0.0879
0.0993
0.1049
0.1169
0.0993
0.0713
0.0504
0.0544
0.1411
0.2022
0.2308
0.1840
0.1690
0.1869
0.2089
0.2611
0.2405
0.2364
0.2690
0.3257
0.3486
0.2761
0.2728
0.2751
0.2548
0.1707
0.0994
0.0768
0.0533
0.0514
0.0367
0.0444
0.0707
0.0721
0.0795
0.0520
0.0611
0.0490
0.1025
0.1341
0.1945
0.1843
0.1627
0.1716
0.1432
0.1612
0.1232
0.1685
0.1544
0.1407
0.0761
0.0493
0.0285
0.0549
0.0946
0.1363
0.1408
0.1648
0.2448
0.2695
0.7115