You can use a for loop with the : operator to iterate over a range of values. The syntax is as follows:
main.m55 chars4 lines
where start is the starting value, step is the step size, and end is the end value. For example, the following code will loop over the numbers from 1 to 10 incrementing by 2:
main.m32 chars4 lines
This will output:
main.m10 chars6 lines
You can also use the linspace function to create a range of linearly spaced values, and then loop over those values. The syntax is as follows:
main.m89 chars5 lines
where start is the starting value, end is the end value, and num_steps is the number of steps (i.e. the length of the range). For example, the following code will loop over the numbers from 0 to 1.5 with 4 steps:
main.m62 chars5 lines
This will output:
main.m12 chars5 lines
gistlibby LogSnag