sum between row in matrix
    조회 수: 4 (최근 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. 
댓글 수: 0
채택된 답변
  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 Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

