필터 지우기
필터 지우기

How should do i get rid of this error?

조회 수: 1 (최근 30일)
LM
LM 2017년 11월 23일
댓글: Walter Roberson 2017년 11월 23일
for i=1:length(no)
Distance=[];
k=0;
end
for j=1:length(no)
if j~=i
sum_squ_diff=sum((stock(i).price-stock(j).price).^2);
Distance(k,:)=[stock(j).permno, stock(i).permno, sum_squ_diff];
k=k+1;
end
end

채택된 답변

Birdman
Birdman 2017년 11월 23일
You say that k=0 at first and then on line
Distance(k,:)=[stock(j).permno, stock(i).permno, sum_squ_diff];
you try to reach to
Distance(0,:)
This is the error. Change it.
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 11월 23일
Also, every iteration of
for i=1:length(no)
Distance=[];
k=0;
end
is doing exactly the same thing. There is no point in doing those more than once.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by