Hi there guys,I have written a simple code (shown at the bottom). the problem is that when the loop starts and goes to the next iteration the vector size of the previous calculation is stored...why? every time a new iteration starts isn't suppose to start fresh. for debugging purposes I see the lengths of vector each iteration makes and to my surprise the vector size from the previous iteration is kept. how do I make this loop so at each iteration, its a fresh start of the variables. please help. the output i get is shown below along with how its suppose to come out
len = 4 >>this is correct
len2 = 4 >>this is correct
len = 0 >>this is correct
len2 = 4 >>this should be 0
len = 1 >>this is correct
len2 = 4 >>this should be 1
len = 0 >>this is correct
len2 = 4 >>this should be 0
len = 2 >>this is correct
len2 = 4 >>this should be 2
if truedata = [1,3,5,7,1,5,1,7,8,1];for ii = 1:5indxe = find(data' == ii); %find value
%to find the row in which the value resides in
for j = 1:length(indxe) indx_row(j,:) = floor(((indxe(j)-1)/8)+1); %each row increment is 0.125
endlen = length(indxe)len2 = length(indx_row)end end
Best Answer