sum between row in matrix

1 次查看(过去 30 天)
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.

采纳的回答

Tina
Tina 2022-1-19
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by