sum between row in matrix

2 Ansichten (letzte 30 Tage)
FARAHIDA HANIM MAUSOR
FARAHIDA HANIM MAUSOR am 19 Jan. 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.

Akzeptierte Antwort

Tina
Tina am 19 Jan. 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

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by