Clear Filters
Clear Filters

last cell is storing too many garbage values

1 view (last 30 days)
SOUVIK DATTA
SOUVIK DATTA on 17 May 2019
Commented: Guillaume on 17 May 2019
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 Comment
Guillaume
Guillaume on 17 May 2019
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;

Sign in to comment.

Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!