Tuesday 22 February 2011

MATHWORKS MATLAB PRACTICE PROBLEMS


Assignment:
1)
Create an M-file in which you give an input and it displays the table of that number:
Example:
>> “name of m-file”
>> What is your desired number? “Enter 2 or any other”
>> 2x1=2
      2x2=4 and so on…



2)
There are many formulae for computing π (the ratio of a circle’s circumference to
its diameter). The simplest is
π/4= 1− 1/3+ 1/5− 1/7+ 1/9−··· (8.4)
which comes from putting x= 1 in the series
arctanx= x− x3/3 +x5/5 −x7/7 +x9/9 −···(8.5)
 Write a program to compute π using Equation (8.4). Use as many terms in the
Series as your computer will reasonably allow(start modestly,with100 terms,
say, and rerun your program with more and more each time). You should
find that the series converges very slowly, i.e. it takes a lot of terms to get
fairly close to π.
3)
The Fibonacci numbers are generated by the sequence
1,1,2,3,5,8,13,...
Can you work out what the next term is? Write a recursive functionf(n) to
compute the Fibonacci numbersF0 toF20, using the relationship
Fn =Fn−1+Fn−2,
given thatF0=F1=1

1 comment: