按特定索引值的数组总和
44次观看(最近30天)
显示较旧的评论
嗨,我有两个阵列。一个包含索引和第二个数组(Hasil_tambah_array)的第一个数组,其中包含以下值的值:
索引=
4
2
4
hasil_tambah_array =
3.6881
0.8506
0.0132
0.8506
10.5147
12.5147
14.5074
21.8003
11.2145
18.5074
I try to sum the second array as per index such as 3.6881,0.8506,0.0132 and 0.8506 (since the 1st index is 4) will be sum together . Then 10.5147 and 12.5147 (since the 2nd index is 2) will be sum up and respectively (next will be the rest since the index is 4).
感谢您的时间解决这个问题。TQIA。
0评论
接受的答案
更多答案(1)
KALYAN ACHARJYA
2021年5月29日
编辑:KALYAN ACHARJYA
2021年5月29日
结果= sum(second_arary(first_array))
更多的
结果= sum(hasil_tambah_array(index))
2条评论
KALYAN ACHARJYA
2021年5月29日
索引= [4
2
4];
hasil_tambah_array = [3.6881
0.8506
0.0132
0.8506
10.5147
12.5147
14.5074
21.8003
11.2145
18.5074];
结果= sum(hasil_tambah_array(index))
输出:
结果=
2.5518
更多:与
>> 0.8506+0.8506+0.8506
ans =
2.5518