10.1 Sequences

The code below plots the first 20 terms of the sequence $\{.9^n\}$.

>> n = 1:20; >> a = .9.^n; >> plot(a,'.')

The following code uses a for loop to compute the third through tenth terms of the recursively defined Fibonacci sequence.

>> a(1)=1; a(2)=1; >> for n=3:10; a(n)=a(n-1)+a(n-2); end >> plot(a,'.')

If you're interested in the limit of a sequence, then it may be preferable to progressively change the scale on the input axis of your plot as illustrated below.