To count from -1 to 101 in MATLAB, you can use a for loop with an if statement to check if the current value is within the desired range. Here's an example code block that accomplishes this:
main.m58 chars6 lines
Explanation:
for i = -1:101
.i
is greater than or equal to 0. This ensures that we only display values between 0 and 101.i
meets this condition, we display it using the disp()
function.Note that this code block assumes you want to count from -1 to 101, inclusive of 0 and 101. If you want to exclude these values, you can change the loop to for i = 0:100
and the if statement to if i > 0
.
gistlibby LogSnag