stuck doing calculation in same table

1 visualización (últimos 30 días)
Khairul nur
Khairul nur el 9 de Feb. de 2021
lets say i have a table 2x10 kira rows and a variable cluster
kira_row=
[3 3 2 2 1 2 1 1 2 3] %cluster
[1 5 10 17 0 9 1 2 16 5]%value
cluster=1
what i want to do is to get two value a and b
a is the sum of value in the same cluster, meanwhile b is the sum of value in other cluster
for example the current cluster is 1 the a value is
value a= 0+1+2
meanwhile for value b there will be two since the number of cluster is 3
value b for cluster 2 is = 10+17+9+16
value b for cluster 3 is = 1+5+5
here is some code i had but cant finish when calculating value b. Please help me figuring how i want to calculate the value of b's
no_of_cluster=3
valueof_a = zeros(1,[])
valueof_b = zeros(1,[])
calc_a=0
transpose_idk =[3 3 2 2 1 2 1 1 2 3]
kira_row=[1 5 10 17 0 9 1 2 16 5]
append_cluster=[transpose_idk;kira_row]
append_cluster=array2table(append_cluster)
for cluster=1:no_of_cluster
calc_a=0
for idk_inverse=1:10
kira_atas = append_cluster{1,idk_inverse}
if cluster==kira_atas
value_a= append_cluster{2,idk_inverse}
calc_a=calc_a+value_a
disp("here")
elseif cluster~= kira_atas
%calculate value b
%stuck here
disp("here here")
end
%store value b in table of 1x2 valueof_b(1,
end
%store value a in table of 1x1 valueof_a(1
end
%combine table valueof_a and valueof_b

Respuestas (0)

Categorías

Más información sobre Parallel Computing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by