フィルターのクリア

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 Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by