1. for index = 7:10
With such syntax the variable index goes from 7 to 10 (including) with step 1. So loop will be executed 10-7 +1= 4 times.
Answer. 4.
2. for jj = 7:-1:10
Will not be execupted at all, becourse this syntax (a:-1:b) assumes going back from a to b. And as far as 7<10, it is not possible
Answer. 0
3. for index = 1:10:10
With such syntax the variable index goes from 1 to 10 (including) with step 10. So loop will be executed 1 time.
Answer. 1.
4. for ii = -10:3:-7
With such syntax the variable ii goes from -10 to -7 (including) with step 3. So loop will be executed 2 tims.
Answer. 2.
5. for kk = [0 5 ; 2 3]
With such syntax the variable kk takes value of each column in a matrix. As far as the matrix [0 5 ; 2 3] has 2 columns, the loop will be executed 2 times.
Answer. 2.
Comments
Leave a comment