sum between row in matrix

2 visualizaciones (últimos 30 días)
FARAHIDA HANIM MAUSOR
FARAHIDA HANIM MAUSOR el 19 de En. de 2022
Comentada: FARAHIDA HANIM MAUSOR el 20 de En. de 2022
for i = 1 : graph.n
for j = 1: graph.n
graph.n=10'
graph.edges = zeros( graph.n , graph.n );
A = data.cent(i,:)-data.cent(j,:);
graph.edges(i,j) = sqrt(sum(A));
end
end
hi this is my code. I want to calculate the distance between each object in a matrix data.cent by using SUM function. but keep getting
Not enough input arguments. error
can anyone help me with this? thanks.

Respuesta aceptada

Tina
Tina el 19 de En. de 2022
Try using this
for i = 1 : graph.n
for j = 1: graph.n
graph.n=10'
graph.edges = zeros( graph.n , graph.n );
A(i,:) = data.cent(i,:)-data.cent(j,:);
graph.edges(i,j) = sqrt(sum(A(:,i)));
end
end

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by