Nested for loop not working
17 views (last 30 days)
Nethravathi S on 18 Aug 2021
I code below is not working when i put first for loop statement. i.e. for kk=1:1:7
Not able to figure it out where is the issue.
I have attached the files.
% for kk=1:1:9
% if jj>=162
Bjorn Gustavsson on 18 Aug 2021
You seem to have two for-loops with kk as index. That is not going to work in any robust way. For clarity I've learnt that to avoid these types of problems I am better off numbering my indices: i1, i2, i3 etc (or "naming" them if they correspond to some real quantity like position in x-direction i_x, i_t etc). That way I have reduced (almost removed) the risk of reusing the loop-variable-name in nested loops.