test01-spring08

test01-spring08 - Convert the following if/else statement...

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

View Full Document Right Arrow Icon
CSC 110: Engineering Computation with Matlab Test 1 – Spring 08 Prof. Johnson 1. (25 Points) Use a while loop to search through the following cell array a = {‘amos’, ‘johnson’, ‘test’, ‘myself’}; and stop the while loop when the string ‘test’ is found. 2. (25 Points) The variable stud is an array of student data-structures , which contains the following fields name and age . Use a for loop to compute the average grade for all the students in the student data structure. Store the answer in the variable myave .
Background image of page 1

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

View Full DocumentRight Arrow Icon
CSC 110: Engineering Computation with Matlab Test 1 – Spring 08 Prof. Johnson 3. (25 Points)
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Convert the following if/else statement to a switch statement if (a = = 2) b = 5; elseif (a = = 8) b = 25; elseif (a <= 15) && (a >= 13) b = 50; else b = 35; end 4. (25 points) What is the output based on the function test. function v = test(a,b) t = a(1); z = b(end); if (t == z) v = sprintf( '%d is %d' ,t,z); else i = length(a); j = length(b); if (i == j) v = a.*b; else v = -1; end end end (1) >> a = test([5 2 4],[2 4 1]) >> a = ________________ (2) >> a = test([9 8 20 5],[2 3 4]) >> a = _________________ (3) >> a = test([3 5 1],[1 2 3]) >> a = _________________...
View Full Document

This note was uploaded on 05/01/2011 for the course HCSC 110 taught by Professor Amosjohnson during the Spring '11 term at Morehouse.

Page1 / 2

test01-spring08 - Convert the following if/else statement...

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

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