필터 지우기
필터 지우기

Matlab error for "Assignment has more non-singleton rhs dimensions than non-singleton subscripts".

조회 수: 1 (최근 30일)
Hi, i have error of "Assignment has more non-singleton rhs dimensions than non-singleton subscripts".
Error in Untitled10 (line 205)
distAllTier1(i,j)= sqrt((node(i).x - node(j).x).^2 + (node(i).y - node(j).y).^2);
The details code as follow:
for i = 1:1:numNodes
for j = indPCHTier1
if node(i).tier == 1
if i == j
distAllTier1(i,j) = NaN;
else
distAllTier1(i,j)= sqrt((node(i).x - node(j).x).^2 + (node(i).y - node(j).y).^2);
end
else
distAllTier1(i,j) = NaN;
break;
end
end
end
The result for
sqrt((node(i).x - node(j).x).^2 + (node(i).y - node(j).y).^2);
is:
ans =
10.295630140987001
21.213203435596427
Then the "distAllTier1(i,j)" cannot support the value. How can i solve this problem?
Thanks :)

채택된 답변

KSSV
KSSV 2018년 9월 27일
sqrt((node(i).x - node(j).x).^2 + (node(i).y - node(j).y).^2);
The output of above is 2*1..and you are trying to save output into a single scalar..
distAllTier1(i,j)
so the error is popping out. I think the output of sqrt() should be a scalar. Show us the complete code to get more help.
  댓글 수: 14
KSSV
KSSV 2018년 9월 27일
[distAllTier1{i,:}]
Try the above line alone.....this should give you a vector.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by