CM0268_Exam_2010_SOLNS

CM0268_Exam_2010_SOLNS - CM0268 SOLUTIONS CARDIFF...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CM0268 SOLUTIONS CARDIFF UNIVERSITY EXAMINATION PAPER Academic Year: 2009/2010 Examination Period: Spring Examination Paper Number: CM0268 SOLUTIONS Examination Paper Title: Data, Audio, Graphics and Image Signal Processing with MATLAB SOLUTIONS Duration: 2 hours Do not turn this page over until instructed to do so by the Senior Invigilator. Structure of Examination Paper: There are 13 pages. This examination paper is divided into 2 sections. There are 4 questions in total. There are no appendices. The maximum mark for the examination paper is 70 and the mark obtainable for a question or part of a question is shown in brackets alongside the question. Students to be provided with: The following items of stationery are to be provided: ONE answer book. Instructions to Students: Answer 3 questions. Answer the question 1 from Section A and two out of three questions from Section B. Questions from each Section should be answered in the same answer book. The use of calculators without programmable memory is permitted. The use of translation dictionaries between English or Welsh and a foreign language bearing an appropriate departmental stamp is permitted in this examination. 1 PLEASE TURN OVER
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CM0268 SOLUTIONS Section A Question 1 is compulsory Q1. (a) What is the output from the following MATLAB statements: i. a = 1, b = 2, c = a + b [1] Output is: >> a = 1, b = 2, c = a + b a = 1 b = 2 c = 3 1 Mark — Unseen Problem ii. a = 1:2:5; b = a * 2 [1] Output is: >> a = 1:2:5; b = a * 2 b = 2 6 10 1 Mark — Unseen Problem iii. a = [1 3]; b = a’ * a [2] Output is: >> a = [1 3]; b = a’ * a b = 1 3 3 9 2 Marks — Unseen Problem iv. a = [1 6 8]; b = mean(a) * ones(size(a)) [2] Output is: 2
Background image of page 2
CM0268 SOLUTIONS >> a = [1 6 8]; b = mean(a) * ones(size(a)) b = 5 5 5 2 Marks — Unseen Problem 6 Marks (sub part total) (b) The following MATLAB statements contain an error, state what the cause of the error is and correct the statement: i. a = 5:10; a([6 8]) = [] [2] Error is: >> a = 5:10; a([6 8]) = [] ??? Index of element to remove exceeds matrix dimensions. Solution is to use the correct index to address the elements (such as 6 and 8) – for example, use a([2 4]) = [] instead. 2 Marks — Unseen Problem. One for cause and one for correction ii. a = 1:8; a(2:3) = [5]; a(4:6) = [8 6]; [4] Error is: >> a = 1:8; a(2:3) = [5]; a(4:6) = [8 6]; ??? In an assignment A(I) = B, the number of elements in B and I must be the same. Solution is to make the array [8 6] of the same size as the index 4:6 (or vice versa), e.g. change 4:6 to [4 6] or 4:5 , depending on what was meant to do. 4 Marks — Unseen Problem. 2 for cause and 2 for correction iii. a = 1:5; b = a * a + 3 * a + 1; [4] Error is: >> a = 1:5; b = a * a + 3 * a + 1; ??? Error using ==> mtimes Inner matrix dimensions must agree. The part of the code causing problem is a * a as the inner dimension does not agree. Since 3 * a is also a 1-by-5 matrix, a simple solution is to change the product to a element-wise product, i.e. change a * a to a . * a . 4 Marks — Unseen Problem. 2 for cause and 2 for correction 10 Marks (sub part total) (c) Give MATLAB code to achieve the following: i. For a given vector v , output the vector in reverse order. [2] Solution is: v(end:-1:1) 2 Marks — Unseen Problem.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 13

CM0268_Exam_2010_SOLNS - CM0268 SOLUTIONS CARDIFF...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online