MATLAB EXTRA 2

studied byStudied by 0 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 55

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

56 Terms

1

From what distribution does rand() function return value?

Uniform

New cards
2

Based on the code below, c is the_ of a

a = rand(I, II);

b = sort (a);

c = b(1, ceil (end/2);

Median

New cards
3

What does the Profiler track?

Execution time

New cards
4

Which code block contains the correct syntax for a while loop?

a = 0 ; *

while a < 5

a = a + 1 ;

end

New cards
5

You have written a function myfun and want to measure how long it takes to run, which code segment will returnt the time in conds it takes myfun to run?

b. tic; * myfun (); toc;

New cards
6

What is %% used for?

code sections

New cards
7

What is the character NOT used for

Cell array access

New cards
8

Which function could you use for multiple linear regression

Regress

New cards
9

For which of these arrays do mean, median and mode return the same value

[01 1 1 2]

New cards
10

You are in the middle of a long MATLAB sessions where you have performed many analyses and made many plot. You run the following commands, yet a figure window doesn't pop-up on the top of your screen which you plot, what might be the issue

x = [-1: 0.1: 1]; y = x.^2; plot (x,y)

you plot is in a figure window that was already open, hidden behind other windows on your screen

New cards
11

How do you access the value for the field name in structure S

S name

New cards
12

What built-in definition does i have

basic imaginary unit

New cards
13

Which statement is equivalent to this loop

a = [123; 456];

b=zeros (size(a));

for i row = 1: size(a, 1)

for i_col = 1: size(a,2)

b (i_row, i_col) = a(i_row, i_col^2);

end

end

b = a.^2;

New cards
14

You have plotted values of cosine from -10 to 10 and want to change the x-axis tick marks to every pi, from -3pi to 3pi, which statement will do that

xticks (-3pi:pi:3pi)*

New cards
15

What is the value of c a = ones (1,3); b = 1:3; c = conv (a,b)

[1 3 6 5 3]

New cards
16

Which function cannot be used to random sample data

resample

New cards
17

Which choice is correct syntax for a switch statement

x = 7

switch x

case 2

disp ("two");

otherwise

disp ("not two");

end

New cards
18
<p>picture</p>

picture

c=inf

New cards
19
<p>What is true of a handle class object</p>

What is true of a handle class object

all copies of handle objects refer to the same underlying object

New cards
20

Which choice has a different final result in f10 than the other three

f10 = 1 ;

i = 1;

while i <= 10

i = i + 1

f10 = i * f10;

end

New cards
21

Which choice will not give you a 5x5 identity matrix

indentity (5)

New cards
22
<p><span>my_func is a function as follows. What is the value of a at the end of the code beneath?</span></p>

my_func is a function as follows. What is the value of a at the end of the code beneath?

1

New cards
23
<p><span>Which choice add b to each row of a?</span></p>

Which choice add b to each row of a?

a=a + repmat(b,4,1);

New cards
24

Which statement returns the roots for the polynomial x² + 2x - 4 = 0?

roots([1 2 -4]

New cards
25

What is the set of possible values that a may contain?


a = randi([1, 10]);
a(3) = 11;
a(a > 2) = 12;

1, 2, 12

New cards
26

Which statement is true about the sparse matrix?

sparse matrices always use less memory than their associated full matrices

New cards
27

Which statement using logical indices will result in an error?

a = 1:10;

b = a(a > 6 && a < a')

New cards
28

Which is not a function that adds text to a plot?

label

New cards
29

What kind of files are stored with .mat extension?

Stored variable files

New cards
30

Which statement returns 1 (true)?


a = 'stand';
b = "stand";
a. a == b

a == b

New cards
31

What does E contain?


C = {'dog', 'cat', 'mouse'};
D = {'cow', 'piranha', 'mouse'};
E = setdiff(C, D);

E = {'cat'} {'dog'}

New cards
32

Where in UI can you see what variables have been created, their values, and their class?

workspace

New cards
33

If you run this piece of code, you will get an error, why?


a = [0 1 2 3; 4 5 6 7];
a = a^2

you are attempting to multiply a non-square matrix by itself causing a dimension mismatch

New cards
34

Which command will create a 10-element vector v with variables from 1 to 10?

v = 1:10

New cards
35

For a 5x5 array, the two subscript indices (4,2) indexes the same location as linear index?

9

New cards
36

What is the difference between global variable and persistent variables?

global variables are accessible outside the function scope.

New cards
37

How is the random seed for MATLAB's random number generator first initialized in a MATLAB session?

seed is set to a static default value on start up

New cards
38

At what will MATLAB look first for a called function?

functions within the current directory

New cards
39
<p>Picture</p>

Picture

5 2

7 4

New cards
40

Which statement will return all the odd numbers from 1 to 9?

1:2:9

New cards
41

What is the size of 'b'?


a = [1 2 3];
b = repmat(a, 3, 2);

2x9

New cards
42

What statement reverses vector a?


a = [1 2 3 4];

a(:,end:-1)

New cards
43

Which command will create a column vector with the same values 7, 8, and 9

c = [7 ;8; 9]

New cards
44

What do you call in the command window to see all the variables in the workspace and their classes.

whos

New cards
45

You wrote a new function named snap in an m-file and when you call it, you're not getting the output you expect. You previously wrote a different function named snap, which you think might also be on the search path. Which command can you use to see if the old snap function is being called?

to include a variable greater that 2GB

New cards
46

Which choice cannot add a directory to the search path?

the savepath function

New cards
47

Which is not a function to plot three-dimensional data?

grid

New cards
48

What is a key difference between && and &?

&& & employs short-circuiting behavior and & does not.

New cards
49

What is the result of this code? s = 'abcd'; s(3) = 'x'

a 1x3 string array

New cards
50

In which case would you use varargin in a function you write?

You want to include optional input arguments.

New cards
51

What does e contain?


c = [9 8 0];
d = [0 0 1];
e = union(c,d);

e = [0 1 8 9]

New cards
52

What does this function print?


a = 1;
for i_loop = 1:6
disp(a);
end

: nothing will print

New cards
53

Which statement returns the character array 'alone'?


b = ['stand' 'alone'];

b(6:end)

New cards
54

What does b contain?


a = [9 8 8 19 6 1 19 6 6 19];
b = unique(a)

b = [1 6 8 9 19]

New cards
55

Which code shows the use of ellipsis in MATLAB?

A = [123; ... 567]

New cards
56

What is the advantage of MATLAB over other computing software with matrix dimensions?

Real time user-defined memory allocation

New cards
robot