You can use a for loop in MATLAB along with a conditional statement that checks if the loop variable (i in this case) is smaller or equal to a certain value. Here is an example code:
main.m55 chars6 lines
In this code, the loop runs from i=1 to i=10, but the if statement inside the loop only executes if i is smaller or equal to 5, which means the loop will only display the values of i from 1 to 5.
You can modify the loop variable range and the conditional statement as per your specific requirements.
gistlibby LogSnag