BACK
Lab 1: Introduction to Matlab

In order to start numerical experiments with dynamical systems, you need to learn a computer language that will allow you to model various dynamical systems and provide means for graphical representation of the results.  One of such languages is called 'Matlab'.  It is relatively easy to learn and use.  Your first lab assignment is to master the basics of Matlab in order to be able to use it for numerical exploration of simple dynamical systems.

ASSIGNMENTS:

1. Use Internet Explorer to access Matlab at http://www.mmc.le.ac.uk/matlab/gettingstarted/

Work your way through the tutorial.  Pay special attention to the syntax, use of graphics and programming in Matlab.  You should gain sufficient understanding of Matlab in order to complete the next assignment.
2.  a) Write a Matlab program of the function sumpower(n,k) which computes the sum of the powers of the first n integers

S(n,k) = 1k + 2k + 3k + ... + nk

for given integer numbers n > 0 and k > 0.

Hint:  The program should start with the word function and contain a for loop.

To test your program, obtain the following output at the Matlab prompt:

>> s = sumpower(1,1)
s =
     1
>> s = sumpower(5,2)
s =
    55
>> s = sumpower(24,3)
s =
        90000
>>
    b) Write a Matlab program (m-file) which uses the function sumpower to compute the sum of squares S(n,2) for n = 1,...,10,  plots the result as a function of n together with the function f(n) = n(n+1)(2n+1)/6, thereby verifying the formula

 12 + 22 + 32 + ... + n2 = n(n+1)(2n+1)/6 .

    The two functions should be clearly visible in the figure.  Hint: Use lines and dots of different styles and/or colours.

3.  As the Lab Report No. 1, hand in the text of the Matlab programs in a) and b) and the figure generated in b).

BACK