200

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Unlike numeric or character arrays, structure arrays can store different data types within the same array***

TRUE

When using the disp command, all of the information to be printed must be of the same general type (all numbers or letters), leading you to sometimes need to perform data type conversions with commands such as num2str

TRUE

With few exceptions, 2nd order or higher diff eq must be converted into an equivalent system of first order diff eqs before they can be integrated numerically

TRUE

Match the following concepts to their appropriate description: a. solve b. diff c. int d. simplify

a. symbolically solves linear and other equations b. c. d.

MATLAB uses a hierarchical system for organizing plotting information. Which of the following choices are in that hierarchy? a. plot objects b. annotation axes c. axes d. user interfaces

all

Of the following, select all the key parts to every user-defined function a. comments that describe other parts of the fxn b. the input(s) of the function (if applicable) c. the name of the function d. the output(s) of the function (if applicable)

all

Consider the following code fragment: x = 3; switch x case 1 disp('Squirtle') case 3 disp('Charmander') case 2 disp('Bulbasaur') otherwise disp('Pikachu') end What will display in the command window from a run of this code fragment? a. Pikachu b. Charmander c. Bulbasur d. Squirtle

b

How large is a boolean value? a. 2 bits b. 1 bit c. 2 bytes d. 1 byte

b

In the main script of a file exists the following code fragment: x = 5; z = adding_function(x); In a separate function file exists the following function: function [y] = adding_function(x) y = x + 1; end What value of y is recorded in the workspace visible in the MATLAB GUI at the end of a run? a. y is not recorded in the workspace visible in the MATLAB GUI because it is outside the main scope of the script b. y = 6 c. y = 4 d. y = 5 e. y = [ ] (underdefined)

b

Picture a figure containing 24 subplots, arranged as if it had 6 rows and 4 columns. Which subplot command is associated with operations for the plot in the third row, second column of the figure? a. subplot(6,4,9) b. subplot(6,4,10) c. subplot(9,6,4) d. subplot(10,6,4)

b

Unless manually specified otherwise, which is the first plotline color MATLAB will use? a. puce b. blue c. red d. green

b

What happens if you try to numerically solve a stiff ODE? (using ode45) a. impossible to determine, as stiffness is only an analytical property b. the solution result tends to break down unless you use extremely small step sizes c. nothing special happens - stiffness has no meaningful impact on the numerical solutions of ODEs d. the solution result will generally be excellent since it is only non-stiff systems that one needs to worry about

b

What is the role of break? a. To force MATLAB to not rest between loop iterations b. To cause the termination of the smallest enclosing loop c. To give MATLAB a chance to rest between loop iterations d. To skip the rest of the loop iteration, advancing to the next loop pass

b

Which of the following best describes a sentinel loop? a. a loop that executes a fixed number of times b. a loop that occurs over and over until a special condition occurs c. a loop that has been coerced into behaving like a do while loop d. a loop that will only execute if a special condition occurs

b

Which of the following distinguishes MATLAB from many (but not all) other programming languages? a. the ability to declare variables b. the ability to perform plotting within the language itself c. the ability to allow the programmer to make logic errors that nevertheless interpret or compile, as appropriate d. the ability to document one's code via comments

b

Which of the following image types has image data stored as an m x n x 3 matrix? a. intensity images b. true color images c. indexed images d. peaks images

b

Which of the following numerical ODE solutions techniques should generally be the first technique you try if you know the system is stiff? a. ode45 b. ode15s c. ode23 d. ode113

b

a user stores a variable x in memory. The command y = isreal(x) is then entered, and the command window displays y = 0. Which of these is the correct interpretation of what happened? a. x evaluated to a real number b. x evaluated to a complex number c. MATLAB didn't understand what you asked it to do d. x evaluated as x = 0. e. x evaluated as x = 1

b

consider the following code fragment: w = [1 5 4 3] x = find(w<=3) what will be the value of x at the end of a run? a. x = [1 4] b. x = [1 3] c. x will not have a value due to syntax error d. x = [ ]

b

Which of the following are good strategies for improving performance of one's MATLAB code? Select 2 a. Always allowing MATLAB to print variables b. pre-allocating the size of a vector c. Ignoring feedback from the computer, since computers cannot think for themselves d. Using the profiler to observe/correct bottlenecks

b,d

Which of the following choices should have an end at the end of a code fragment for the syntax to be valid? More than one selection may be correct. a. script b. switch selection structure c. function file d. if selection structure

b-d

Consider a system of 1000 simultaneous linear equations, which are put into a matrix equation Ax = b. Which solution approach is generally the best choice computationally? a. The numeric implementation x = inv(A)*b b. x is calculated by hand without a computer using a technique such as cramer's rule or Gaussian interpretation c. The numeric implementation x = A\b d. Guess and check

c

How much memory would be required to store a dense 100 x 100 matrix of double point precision floating point numbers? a. 80 MB b. 40 MB c. 80 KB d. 40 KB

c

What is the primary difference between the image and imagesc commands? a. the presence or absence of gradual retouching b. how much flattening is applied to an image c. the presence or absence of image scaling d. nothing, the commands are identical

c

What is the role of continue? a. to cause the termination of the smallest enclosing loop b. to give MATLAB an opportunity to rest between loop iterations c. to skip the rest of the loop iteration, advancing to the next loop pass d. to force MATLAB to not rest between loop iterations

c

What output will display from this code fragment? number_of_laws = 4; fprintf('there are %8.2f laws of thermodynamics\t', number_of_laws) a. There are 4.00 laws of thermodynamics >> b. There are 4.00 laws of thermodynamics >> c. There are 4.00 laws of thermodynamics >> d. There are 4.00 laws of thermodynamics >>

c

for i = 1:2 for j = 3:4 fprintf('i: %i, j: %i\n', i, j) end end What will be the value of j at the end? a. 1 b. 3 c. 4 d. 2

c

x == 3; while rem(x,2) == 0 || x > 3 x = x + 1; end fprintf('Final value of x: %i\n', x) What will be displayed after a code run? a. the loop will never finish terminating, so the print statement will never be executed b. Final value of x: 4 c. Final value of x: 3 d. Final value of x: 10

c

What commands is/are used to declare a variable as a symbol? a. smys b. symbol c. sym d. syms

c,d

diag(A)

creates a column vector & extracts diagonal elements of 2d matrix

Chars in MATLAB are represented by what value in memory? a. decimal value b. hexidecimal value c. EBCDIC value d. ASCII value

d

Consider a system of N + 1 linearly independent equations with N unknowns. What do you know about the system? a. The system is perfectly defined; the solution to this system is deterministic and exact b. none of the other choices are correct c. The system is under-determined, and so there are infinitely many solutions for the N variables d. The system is over-determined, and so there is no exact solution that will satisfy all N + 1 equations perfectly

d

What default order does MATLAB store field names for structure arrays? a. It is not deterministic (ie normally no way to determine this) b. dictionary order (ASCII or EBCDIC as appropriate) c. English alphabet order d. in order of creation

d

counter = 0; for k = 1:10 if k < 2 && k > 5 counter = counter + 1; end end what will the value of the counter be? a. counter = 5 b. counter = 3 c. there is a syntax, the code will not run to completion d. counter = 0

d

Which of the following MATLAB commands can be used to adjust the lighting of a plot? a. beta b. drawline c. hidden d. flashlight e. alpha f. camlight

f

fliplr(A)

flips a matrix horizontally

Which statement will print from the following code fragment? x = [1 2]; if x == 1 disp('Construction') elseif x == 2 disp('Lighting') elseif x >= 2 disp('Mechanical') else disp('Structures') end what statement will print from the following code fragment?

structures

consider the following code fragment: my_root = @(m,n) m.^n; y = 9; x = 0.5; z = my_root(y,x); The value at the end of the run is:

3.0

zeros(m,n)

Creates matrix of zeroes in m # rows and n # columns

Both = and == can be used interchangeably in MATLAB, which is untrue in many other programming languages

FALSE

Everything that can be done with an if selection structure can also be done with switch selection structures

FALSE

For a variety of reasons, it is a good programming practice to indiscriminately use global variables

FALSE

Image data is stored as (a) structure array(s) in MATLAB

FALSE

The colors in an intensity image are not determined via a colormap

FALSE

The default numeric data type in MATLAB is the single

FALSE

When analytically integrating with the symbolic engine, one does not need to remember to add the constant of integration to the result of an indefinite integral calculation (MATLAB will display one automatically)

FALSE

the ' operator and the built in function transpose act identically under all circumstances

FALSE

As discussed in lecture, there are 3 primary steps to writing a file with fprintf command. First step: Second step: Third step:

First step: open and/or create the file Second step: write to the file Third step: close the file

Meshgrid(x,y)

Maps vector in 2d Array (one x and one y)

flipdu(A)

Not a valid MATLAB command, (flipud(A) flips matrix vertically)

Order of operations in MATLB

PEMDAS

A while loop may never execute, likewise, it is possible for it to never terminate

TRUE

Every esleif needs an if, but not every if needs an else

TRUE

Examples of data types in MATLAB include: doubles, singles, chars, and symbols

TRUE

If a function has multiple outputs, one can usually avoid storing one of the outputs in memory by using the ~ operator

TRUE

In current versions of MATLAB assuming no other commands are in use the use of hold on and hold off commands to plot additional lines will cause those lines on the plot to be of different colors

TRUE

In general, for square matrices A and B, the result of A*B is not equal to B*A

TRUE

In general, one should look to use other features (such as code vectorization or built ins) before using a loop

TRUE

It is important when using a composite simpson's rule to remember to use an even number of subintervals

TRUE

Switches are an excellent choice to test for equality against a set of known values

TRUE

The basic data element in MATLAB is a matrix, even for scalar quantities

TRUE

Unlike numeric or character arrays, cell arrays can store different data types within the same array***

TRUE

MATLAB for loop syntax takes the form: for index = some_variable (some commands) end some_variable could be a scalar, vector, or matrix

TRUE

Not only can some built-in MATLAB functions like diff change their behavior based on the number of inputs or outputs, but they can also behave differently based on the data type(s) of the variable(s) put into them

TRUE

assume any possible value of y would be scalar code #1 counter = 0; if y == 2 | y ==5; counter = counter + 1; end code #1 counter = 0; if y == 2 counter = counter + 1; elseif y == 5 counter = counter + 1; end T/F: These 2 are two different approaches that execute the same task

TRUE

assuming both x and y have the same number of elements, the command plot(x,y) will plot y vs x

TRUE

for k = 1:inf (statements) if (some condition) break; end end This is generally a practice you should not make use of

TRUE

A = [ 1 2 3 4]; B = [ 2 4: 6 8]: C = A*B Which result is most likely from this code? a. C = [14 20 30 44] b. C = [ 2 8 18 32] c. Nothing, because there is a syntax error d. C = [2 0 0 2]

a

Assume a properly defined MATLAB function is called my_function. The command nargin('my_function') returns -1. What is the correct interpretation of this result? a. There are multiple ways to use that function, so MATLAB cannot provide a single definitive answer b. There is a syntax error, so MATLAB is unable to proceed with the requested operation c. There is only one input to that function d. There is a logic error, resulting in garbage in, garbage out (GIGO)

a

Consider a matrix system Ax = b. You know that A is square and non-invertible. you use its inverse to calculate x, what will happen? a. MATLAB will happily calculate the value of x, yielding a result that is probably wildly wrong. b. It is impossible to postulate what the behavior will be like, since it strongly depends on other factors not present in this problem c. MATLAB will not perform the operation because it will recognize the matrix is non-invertible d. MATLAB will happily calculate the value of x, yielding a result that is (but not exact) to the correct answer.

a

If you wanted to use a built in function to numerically integrate a known function (but a function which you do not have discrete data points) which function would you use? a. integral (previously quad) b. int c. trapz d. riemann

a

In terms of amounts of required storage, how do these data types compare? a. single < complex number consisting of singles = double b. single < complex number consisting of singles < doubles c. single < double < complex number consisting of singles d. double < complex number consisting of singles = single

a

The basic unit of information in any computer is the: a. bit b. byte c. matrix d. mbps

a

The inertia tensor for a solid sphere of radius r and mass m is given as: I = 2/5mr^2 0 0 0 2/5mr^2 0 0 0 2/5mr^2 presume for the purposes of this question that you can treat a sensor like a matrix, and that the problem is unitless. Let m=5 and r=2 and let this matrix be stored as the variable I in MATLAB. Which of these sections would the command I(:,1) return? a. ans = 8 0 0 b. ans = 8 0 0 c. ans = 0 0 8 d. ans = 0 0 8

a

What is the linear interpolation between the points (2,6) and (4,10) a. y = 2x + 2 b. y = 3x + 2 c. y = 1/2x + 5 d. y = 1/2x + 8

a

Which of the following is the most appropriate way to measure wall time? a. clock and etime b. writing a while loop that executes once every second & counting the number of iterations of the loop c. cpu time d. tick and tock

a

consider the following code fragment: w = [1 5 4 3]; x = find (w<=3) what will be the value of x at the end of the run of this code? a. x = [1 4] b. x = [1 3] c. x will not have a value due to a syntax error d. x = [ ]

a

Select each of the good reasons to create or use programmer-defined functions. Up to two are correct a. Programming convenience b. code maintainability c. code obfuscation d. programming discipline

a & b

Which of the following characters would be allowable as the last character of a variable name? @ # a 3

a, 3 (only letters and numbers allowed in a variable name)

Which of these pitfalls should you generally avoid? Select all that are correct. a. Extrapolating data into the future b. Assuming anything that came out of a computer is correct c. Fitting a regression line through the origin d. overfitting a polynomial regression to your data set

a,b,d

Reasons to avoid using loops in MATLAB: select 3 a. low performance (clock time) b. the ability to use matrices as indices for loop c. an assortment of built-in array operations d. built-in tools such as the find command

a,c,d

What are the advantages of using ezplot for plotting? a. MATLAB will automatically title the plot with the equation of the function being plotted b. MATLAB will automatically add legends to the plot c. One does not have to plot discrete data (like one must do to use the plot command) d. different versions of ezplot exist for different types of data (ezplot3 or ezpolar)

a,c,d

Which of the following data arrangements can a MATLAB for loop index over? Up to 3 of the selections are correct. a. vector b. transpose c. scalar d. matrix

a,c,d

Match the following concepts to their definitions: a. dense matrix b. sparse matrix c. banded matrix d. identity matrix e. singular matrix

a. a matrix in which most of its elements are nonzero b. matrix in which most of its elements are zero c. a matrix whose non-zero elements are confined to a diagonal band d. banded matrix with 1's e. matrix with determinant = 0, no inverse

Match the following concept to its description a. Midpoint rule b. Right point riemann sum c. Left point riemann sum d. Trapezoidal rule e. Simpson's rule

a. fits rectangles underneath, with the height being the midpoint between the left and right points b. fits rectangles underneath using the right point as the height c. fits rectangles underneath using the left point as the height d. uses trapezoids to estimate the area e. fits parabolas underneath the curve

Match the ide to its description or definition a. creates a line between each pair of data points, ignoring the rest of the data b. creates a regression line that tries to capture the trend of all the data c. carried out via difference equations

a. interpolation b. curve fitting c. numerical differentiation

match the fprintf fileID integer representation to its meaning a. 0 b. 1 c. 2 d. -1 e. 5

a. standard input b. command window c. standard error d. file did not open successfully e. file opened successfully


संबंधित स्टडी सेट्स

APUSH First Semester (Final Review #1-4)

View Set

Guide to Computer Forensics and Investigations 5th ed Chapter 4 Review Questions

View Set