Sequences and Series Previous Contents Next

11   Sequences and Series

11.1   Sequences

11.1.1   Defining a sequence a = {an}

In MATLAB there is a natural way to describe a sequence in terms of a list. Recall the sequence {an} is nothing more than a list of numbers indexed by n. But a vector in MATLAB is just the same.
>> a = 1:100;                   % the sequence 1,2, ..., 100
>> b = 1:2:100;                 % the odd numbers between 1 and 100
>> for i = 1:10
>  c(i) = prod(1:i);            % shorthand for the factorial of i
>> end                          % c is the sequence 1!, 2!, 3!,... 10!
>> x = floor(2*rand(1,100))     % a sequence of 100 random coin tosses

11.1.2   Sequence found by iteration: an = f(an-1)

11.2   Series


Previous Contents Next