MATLAB: What is the output

adams predictor-corrector methodfor loop

I am trying to check how the loop works hence, I am displaying the value of n in the for loop but it doesn't seem to work. Why doesn't n get displayed and how is the code (loop) working?
h=0.3;
x=0:h:0.8;
for n=4:length((x)-1)
disp(n)
% Doing something here
end

Best Answer

length of x is 3. When you subtract 1 from a numeric vector you do not change the length so length((x) - 1) is the same length(x) which is 3. So your for loop is
for n=4:3
Which will not execute at all.