(Demonstration by the teacher on the LCD-projector)
Review diagnostic test.
(Demonstration by the teacher on the LCD-projector)
Write a function fact(n)
which implements the factorial function:
![]() |
Use an if-statement and a loop.
Explain to your comrades what the following function does (without trying it in Matlab).
function v2 = albert(v1) % albert(v1) % % Mystery function, explain what it does! % v1 and v2 are vectors % Make v2 an empty vector v2 = []; j = 1; for i = 1:length(v1) if v1(i) > 13 v2(j) = v1(i); j = j + 1; end end
Write a function sumseries1(N)
which computes the sum of the N
first terms in the sequence:
![]() |
Write a function sumseries2(tol)
which computes the sum of the numbers
in the sequence:
![]() |
and stops when the next term is less than tol. Use a while-loop.
Write a function sumdivisible7(N) which computes the sum of all
numbers from 0 to N which are divisible by 7. Hint: the
rem(x, y)
-function computes the remainder of
in
integer division.