for ii = (1:s(1)) mean in matlab

(1:s(1)) creates a vector of s(1) elements starting from 1 and incrementing by 1 in each step. This is most commonly used in for loops to iterate over the elements of a vector.

For example, if s(1) = 5, then (1:s(1)) is equivalent to [1 2 3 4 5].

Here's an example of using it in a for loop:

main.m
% iterating over the vector using for loop
s = [5 2]; % a 2 element vector
for ii = (1:s(1))
    disp(ii); % prints the value of ii in each iteration
end
154 chars
6 lines

This will output:

main.m
1
2
3
4
5
10 chars
6 lines

Here, ii iterates from 1 to 5 (inclusive) because s(1) is set to 5.

related categories

gistlibby LogSnag