MATLAB Software (CSCT3104)

Computer Science - COS

Semester: First Semester

Level: 300

Year: 2019

REPUBLIC OF CAMEROON THE UNIVERSITY OF BAMENDA
Peace Work Fatherland P.O. BOX 39 Bambili
FIRST SEMESTER EXAMINATION
SCHOOL: HTTTC DEPARTMENT: Computer Science OPTION: FCS
COURSE CODE: CSCT3104 COURSE TITLE: MATLAB software
LECTURER: Mr. DEMANOU YMELE CREDIT VALUE: 3
DATE: 14/03/2019 TIME: 1h30 START: 7:30AM END: 9:00AM
Instructions: Answer all the questions
Exercise I(40 marks)
1. Give Matlab commands to solve each of the following linear systems.
(a)



(b)



2. Write a Matlab function that takes as parameter A and B then returns the solution of the linear system
AX=B ;
3. Run the function f for t = 25 and guess what it does.
function res = f(t)
x=1;%First guess
err=1;%Set error to something to get started
while(err>0.1)
x = g(t,x); % call to local function below
err = abs(t-x.^2); % calculate the error
end
res = x
function y = g(t,x)
y = (x.^2+t)./(2*x);
4. A matrix « m »is defined by : >> m = [1 2 3 4; 5 7 8 8, 9 10 11 12; 13 14 15 16];
What will be the result of each of the following command ? m(1, 1:3) ; m(2:end, 3) and size(m, 2).
5. Assume x = pi*[-24:24]/24. Give instructions to plot sin(x)and cos(x) on separated graphs on the same
window, using plot, subplotandfigure. Specify for each sub plot the title, and axis names.
Exercise 2 :(30 marks)
www.schoolfaqs.net
A function f is defined by
󰇛
󰇜

. We want to find the root of f using Matlab.
1. Compare NEWTON-RAPHSON and SECANT METHOD(give at least two aspects)
2. Implement Newton method with the following prototype
function [x,ter] = newtonMethod(x0, g, gp)
wherex0is the first value of x and gp the derivative of g
3. Give the Matlab commands to find the root of function f using your newton Method
4. Write a function to implement LaGrange interpolation method.
www.schoolfaqs.net