SAVE

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

C = 100 K = C + 273

The statement results in an error.

exit

Exits the MATLAB session.

name$

Invalid

pay-day

Invalid

switch

Invalid

log10

Common logarithm

In MATLAB, the % character is the only character that indicates a comment.

True

Complete the statement to obtain a string from the user rather than a number. userName = input("Sally", ______ );

"s"

What two-symbol sequence outputs the percent symbol in fprintf?

%%

Type the formatting operator to display numMeters is a floating-point variable. fprintf("Meters: ____", numMeters);

%f

x * y * z

(x * y) * z

x / 2 + y / 2

(x / 2) + (y / 2)

z / 2 - x

(z / 2) - x

If the previously-entered statement was "num1 = 5", what value will be stored in num2 after the statements "num1 = num1 + num1" followed by "num2 = num1 + 3".

13

What is val after executing the line num = 6; num = num * 2; val = num + 1;

13

Suppose distanceMiles equals 1870, timeSecs equals 343440, and speedMPH equals 55.0. What is the value of speedMPH after calling CalculateMPH?

19.6

For the statement "fprintf("Apples\nPears\nOranges")", how many lines of text will be output?

3

Variable num is initally 2. The command num = num * 2 is typed and entered once; then the up-arrow key is pressed followed by enter, three times. What is num?

32

What is the value stored in luckyNumber after these two statements execute? luckyNumber = 7; luckyNumber = 4;

4

What will the statement "myNum = 2 + 2" store in myNum?

4

What is totCount after executing the following? numItems = 5; totCount = 1 + (2 * numItems) * 4;

41

What is x after executing the line x = 5; y = 9; y = x; x = y;

5

What is the next value after 34 in the Fibonacci rabbits example?

55

Assume apples currently has the value 5 and oranges the value 9. What is the value stored in apples after the following statement? apples = apples + 1;

6

Assume that no variables have been assigned yet in the base workspace. How many variables would be assigned after executing the following code: distancePes = 1000; timeSecundae = 55; RomanUnitsToMPH

8

If the previously-entered statement was "num1 = 9", what value will be stored in num2 after the statement "num2 = num1 * num1"?

81

Assume apples currently has the value 5 and oranges the value 9. What is the value stored in apples after the following statements? apples = oranges; oranges = oranges + 1;

9

If the previous statement was "num1 = 99", what value will the statement "num1" print? Type "error" if appropriate.

99

What symbol at the end of a statement suppresses printing of the result?

;

clear

Clears all variables from the workspace, so all variable values are lost.

clc

Clears the command window. Does not affect the workspace, meaning variables are unchanged.

A comment is only valid if preceded by a MATLAB statement on the same line.

False

A second % ends a comment, thus enabling a statement to appear after a comment on a line, as in: % Increment total % total = total + 1;

False

Engineers must become programming experts before using MATLAB.

False

Expressions must be written on one line.

False

Incremental programming is good practice for beginners, but experienced programmers type large amounts of code between tests.

False

MATLAB's interpreter makes testing pieces of code especially difficult.

False

Only one way exists to decide which custom functions to define.

False

Pseudo-Code is MATLAB code that runs but isn't yet complete.

False

Right after defining pseudo-code, the example created a script.

False

Running the script results in 30 being printed in some form to the command window.

False

The command line statement to run the script is: CostDrive.mlx

False

The following indicates the expression continues on the next line: x = a + b . . .

False

The variables created by the script are eliminated from the base workspace after the script runs.

False

2a

Invalid

_2a

Invalid

log

Logarithm to base e

Matt Labler is a novice MATLAB programmer. He wants to set variable A to 6, B to 9, and C to their sum, with only the values of A and C displaying in the command window. He asks you to check the following statement for bugs: A = 6; B = 9; C = A + B

Matt should use "A = 6, B = 9; C = A + B" instead.

Does 2 + 3 * 4 - 4 equal 16?

No

Does 2 / 2 * 3 equal 2 / 6?

No

Does 2 / 3 ^2 equal 4 / 9?

No

Eps

Not Predefined

J

Not Predefined

e

Not Predefined

inf

Not Predefined

X = 39; Y = 41, Z = X + 17,;

Only Y and Z are displayed.

X = 14; Y = 2, Z = 5

Only Y and Z will display.

NaN

Predefined

who

Prints all variables in the current workspace.

diary

Records into a file almost everything that appears in the command window. The file's name is chosen by the programmer, such as "mysession.txt". "diary off" ends the recording.

cosd

This function's argument units must be in degrees

cos

This function's argument units must be radians

Engineers must capture a specific problem and solution approach correctly and efficiently to use software effectively.

True

Entering the following command line is allowed: CostDrive; CostDrive

True

Incremental programming involves writing and testing a program in small increments.

True

MATLAB can solve a variety of engineering problems including those requiring simulating differential equations and iterative numerical calculations.

True

MATLAB can solve systems of linear equations using simple matrix manipulation.

True

Placing the critical code in a script enabled quick testing of the code for various input values.

True

The use of custom local functions increases the readability of the program.

True

pay_day

Valid

r2d2

Valid

y_____5

Valid

What is the word for a named region in memory used to store a value?

Variable

Does -4 ^ 2 equal -16?

Yes

Does 2 ^ 3 ^ 2 equal 64?

Yes

Write two statements, the first setting apples to 7, and the second setting oranges to apples plus one. Terminate each statement with a semicolon.

apples = 7; oranges = apples + 1;

Write a statement, ending with "- 1;", that decreases the value stored in apples by 1. The output of the statement should be suppressed.

apples = apples - 1;

Write a variable assignment statement that assigns birdFeeders with the current value of variable stockCount, and prints the value of the variable to the command window.

birdFeeders = stockCount

Assume that no variable have been assigned yet in the base workspace. Which statement below would calculate the speed in miles per hour for a distance of 56.9 miles and elapsed time of 73 minutes?

distanceMiles = 56.9; timeSecs = 73*60; CalculateMPH

If all previous statements dealt only with num1, num2, and num3, what value will the statement "num4" print? Type "error" if appropriate.

error

Type a statement (end with ;) to print the value of a variable named width as a decimal integer.

fprintf('%d', width);

Complete the fprintf function call to print the value of variable houseWidth and houseHeight. fprintf("Width: %f, height: %f.", ____ );

houseWidth, houseHeight

What function obtains a number from a user?

input

Complete the statement that prompts the user with "Enter your age:" and assigns the variable userAge with the user-entered value. userAge = ______

input('Enter your age:')

After executing the statements: x = [2, 5, 8]; y = sqrt(x); save('dataAll'); What statement would bring only the square roots of 2, 5, and 8 into the workspace? Do not include the .mat extension.

load('dataAll', 'y') or load dataAll y

Write a variable assignment statement that assigns luckyNumber with 7 and suppresses the output to the command window.

luckyNumber = 7;

Complete the fprintf function call to print the value of variable oceanDepth. fprintf("'Depth is %f", ____);

oceanDepth

Suppose the workspace consists of only two variables x = [3, -1, 4] and y = 98.6. Write a command on the command line that only saves the variable y to the file dataY. Do not include the .mat extension.

save dataY y

Write a statement to save all variables in the current workspace to the file data1.mat from a script.

save('data1')

Assign measuredAngle with the sine of sunAngle plus cosine of sunAngle. sunAngle is in degrees. measuredAngle = ____ ;

sind(sunAngle) + cosd(sunAngle)

Assign travelDist with the square root of milesEstimate. travelDist = ____ ;

sqrt(milesEstimate)

Assign resultVal with the tangent of sunAngle. sunAngle is in degrees. resultVal = ____ ;

tand(sunAngle)

Write a variable assignment statement that assigns totalPets with 3.

totalPets = 3; or totalPets = 3

x + 1 * y / 2

x + ((1 * y) / 2)

x + y ^ 3

x + (y ^ 3)

tempVal = x; x = y; y = tempVal;

x is 99 and y is 22.

tempVal = x; x = y; y = x;

x is 99 and y is 99.

x = y; y = x;

x is 99 and y is 99.

x = y; y = x; x = y;

x is 99 and y is 99.

y + 2 * z

y + (2 * z)


Ensembles d'études connexes

Introduction to Computers Part 2

View Set

What date is today 今天是几月几日?

View Set