To create a range of values from 5 to 85 in intervals of 5, you can use the linspace
function in MATLAB. Here's an example code snippet that uses a for
loop to print out the values generated by linspace
:
main.m328 chars13 lines
This code first defines the start and end values of the range, and specifies the desired interval (in this case, 5). It then uses linspace
to generate an evenly spaced array of values between the start and end values, with a total number of values equal to (end_val-start_val)/interval + 1
.
Finally, the code uses a for
loop to print out each of the generated values on a new line.
gistlibby LogSnag