last cell is storing too many garbage values

1 次查看(过去 30 天)
whenever i am running this loop the last cell is storing too many (say 200) garbage values along with the actual values, how to remove them?.
y3=0;
for i=1:1
for j2=2:dl
h1 =sqrt(( xcor(i)- xcor(j2))^2 + ( ycor(i)- ycor(j2))^2);
for i1=2:8
if (h1 > LagClass(i1-1) & h1<= LagClass(i1-1)+lagint)
y3=y3+1;
GradeInClass{i1}(y3,:)= z(j2);
end
end
end
end
Thank you,
souvik
  1 个评论
Guillaume
Guillaume 2019-5-17
Your code has no comment explaining what it's meant to do. How can we tell what is wrong with it?
Certainly, this line:
GradeInClass{i1}(y3,:)= z(j2);
is very bizarre. For a start you're using : which implies you're going to store a vector in GradeInClass{i1} but you're storing the scalar value z(j2). Secondly, since y3 increments each time you're storing something, you're going to end up with lots of empty rows in each GradeInClass element.
It's very unclear what you're trying to do but I would suspect that the line above is completely wrong.
Also puzzling:
for i = 1:1
This is only going to run once. It's just equivalent to
i = 1;

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by