k is the loop index variable in the code that you showed. The loop index variable is always defined after for:
for ??? = ...
^ this is where the loop index available is specified.
This is also shown in the MATLAB documentation:
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!