How should do i get rid of this error?
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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
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 Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!