Matlab Test 1

Ace your homework & exams now with Quizwiz!

The _____ allows a matlab statement to continue to the next line.

...

x = 0 while (x>0) x = x - 1 end disp (x)

0

What are the values in F after the following command is executed: V = 1:4

1 2 3 4

v = linspace (1,4,3)

1 2.5 4

matrixA = [1 5; 4 8; 3 11]; What is the output of the command disp(matrixA*)?

1 4 3 5 8 11

matrixA = [1 5; 4 8; 3 11]; What is the output of the command disp(matrixA)?

1 5 4 8 3 11

What can you NOT start a name with in Matlab?

1st character 0-9

What is the output of the following code: x = 1 if x>0 x = x + 1 end if x>2 x = x+ 2 end

2

s = 0 sum = 0; while s <= 12 sum = sum + s; s = s+4; end

24

For each group of statements, give the final value of x if the initial value of x is 2. For the if-else statements, the final value of x is: if x>0 x = x+1; elseif x>= 2 x = x+2; end

3

What is the value of x after the following code segment is executed? n = [6, 2, 5; 4, 3, 1] x = max(n(:,2)) ;

3

matrixA = [1 5; 4 8; 3 11]; sortedMatrix = sortrows (matrixA, -2); What are the values in the sorted Matrix

3 11 4 8 15

What is the output of the following code segment: format short; disp (pi)

3.1416

x = [45, 23, 17, 34, 85, 33]; count=0; for c=?length(x) if x(c)>=33 count = count +1 end end

4

For each group of statements, give the final value of x if the initial value of x is 2. For the if-else statements, the final value of x is: if x>0 x = x+1; end if x>= 2 x = x+2; end

5

What is the value of x after the following code segment is executed? n = [6, 2, 5] x = max(n)

6

Given the following code segment: x = [1, 2, 3] y = [4, 5, 6] z = [7, 8, 9] myMatrix =(x , y, z); myMatrix =(2:3, 3)?

8 9

% exam01.m ________. a) is a comment b) is an executable statement c) is the beginning of a multi-line comment d) runs the program Exam01.m

A

The ___ function returns the average value a) mean b) median c) ave d) average

A

The ____ function returns the location of the array entries that meet the condition requirements. a) find b) get c) | d) ==

A

The _____ MATLAB rounding functions will help to determine how many bags of 3 cubic feet bags of mulch to buy to cover a 15' by 4' flower bed with 2" mulch? a) ceil b) round c) floce

A

The _____ keeps track of variables defined as you execute commands and their current values. a) workspace window b) command window c) current directory window d) command history

A

What is the output? pi = 429; disp(pi); a) 429 b) 3.1416 c) An error message is displayed

A

Which function clears the command window? a) clc b) clear all

A

Which statement is valid? a) A diary files saves all statements typed and output create in the command window b) A diary files saves only the command statements typed in the command window c) To turn off, a diary file type in "diary exit"

A

i = 100; j=0; Which is true? a) (i>0) || (j>50) b) ~(j<1) c) i<3 d) (j<i) && (i<=10)

A

The Current Directory is present by MATLAB and cannot be changed by you a) True b) False

B

The ____ format option suppresses the extra line-feeds. a) suppress b) compact c) close d) short

B

The dot with the asterisk is not required in the statement. a) True b) false

B

What is sin(pi)? a) 1 b) 1.2246e-016 c) 0

B

______ Requests info from the user at the keyboard. a) menu b) input c) request d) prompt

B

__________ is NOT one of your instructor's rule for variable names a) Be descriptive b) Always capitalize the first letter of a variable c) Use camel backing or the underscore of variables with multiple words d) constant variables are not changed and all capital letters

B

height = [63 67 65 72 60 78 75]; accept = find(height >= 65); a) 63 60 b) 2 3 4 6 7 c) 67 65 72 78 75 d) There are no values in except

B

Names typed in all capital letters are: a) comments b) will cause an error when the programs is run c) are required by the instructor for values that do not change d) are not allowed in Matlab

C

The _____ format option scales fixed point format with four decimal places. a) long b) loose c) short d) bank

C

The _____ operator at the box does not create a vector: a) , b) : c) % d) ;

C

What are the values of x and y after the following code segment is executed? n = [ 5, 2, 1, 4, 3] [x,y] = min(n) a) 1 1 b) 3 1 c) 1 3 d) 5 3

C

What is the output of the following code segment: myValues= [ 4 8 3 7 -9] ; size(myValues) a) size = 5 b) ans = 5 c) ans = 1 5 d) size = 1 5

C

Which does not describe the max() function? a) Finds the largest value in a vector b) Creates a vector containing the largest element from each column of a matrix c) Creates a vector containing the largest element from each row of a matrix d) Finds both the largest value in a vector and its location in the vector.

C

Which is a valid name? a) banner# b) banner number c) bannerNumber d) 903_num

C

Which is not a key word? a) while b) end c) pi d) elseif

C

_____ will display the max value in the following matrix: m=[1 2 3 4; 2 3 4 5; 3 4 5 6]; a) max[max(m)] b) max(m(:)) c) All will display the max value in m d) max(max(m*))

C

After using new -Script in the menu bar, a blank window appears in the _____ where you type. a) current directory b) command window c) workspace d) editor

D

If a = [0:7], what is the length a? a) 1 b) 9 c) 7 d) 8

D

The ___ brackets are needed in place of the box symbols. a) {] b) () c) <> d) []

D

The ____ function returns uniformly distributed pseudorandom numbers. a) vector b) random c) uniform d) rand

D

When MATLAB either access or saves info, it uses _____ unless told differently. a) My Documents b) your C: Drive c) your Comp1200 folder d) the current folder

D

Which of the following is the correct Matlab statement to create: c = [22 17 4]

c = [22; 17; 4]

What is the value of x after the following code segment is executed? n = [6, 2, 5; 4, 3, 1] [x,y] = max(n(:,2)) ;

x = 3 y = 2

What is the value of x after the following code segment is executed? n = [6, 2, 5] [x,y]= max(n)

x = 6 y = 1


Related study sets

Chapter 14 New Beginnings: Single-Parent Families, Remarriages, and Blended Families

View Set

Economics Final Exam Unit One Review

View Set

CIS 105 Smartphones are really Smart: Sound Byte

View Set