MATLAB EXTRA 2

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/55

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

56 Terms

1
New cards

From what distribution does rand() function return value?

Uniform

2
New cards

Based on the code below, c is the_ of a

a = rand(I, II);

b = sort (a);

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

Median

3
New cards

What does the Profiler track?

Execution time

4
New cards

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

a = 0 ; *

while a < 5

a = a + 1 ;

end

5
New cards

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;

6
New cards

What is %% used for?

code sections

7
New cards

What is the character NOT used for

Cell array access

8
New cards

Which function could you use for multiple linear regression

Regress

9
New cards

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

[01 1 1 2]

10
New cards

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

11
New cards

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

S name

12
New cards

What built-in definition does i have

basic imaginary unit

13
New cards

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;

14
New cards

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)*

15
New cards

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

[1 3 6 5 3]

16
New cards

Which function cannot be used to random sample data

resample

17
New cards

Which choice is correct syntax for a switch statement

x = 7

switch x

case 2

disp ("two");

otherwise

disp ("not two");

end

18
New cards
<p>picture</p>

picture

c=inf

19
New cards
<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

20
New cards

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

21
New cards

Which choice will not give you a 5x5 identity matrix

indentity (5)

22
New cards
<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

23
New cards
<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);

24
New cards

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

roots([1 2 -4]

25
New cards

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

26
New cards

Which statement is true about the sparse matrix?

sparse matrices always use less memory than their associated full matrices

27
New cards

Which statement using logical indices will result in an error?

a = 1:10;

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

28
New cards

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

label

29
New cards

What kind of files are stored with .mat extension?

Stored variable files

30
New cards

Which statement returns 1 (true)?


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

a == b

31
New cards

What does E contain?


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

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

32
New cards

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

workspace

33
New cards

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

34
New cards

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

v = 1:10

35
New cards

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

9

36
New cards

What is the difference between global variable and persistent variables?

global variables are accessible outside the function scope.

37
New cards

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

38
New cards

At what will MATLAB look first for a called function?

functions within the current directory

39
New cards
<p>Picture</p>

Picture

5 2

7 4

40
New cards

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

1:2:9

41
New cards

What is the size of 'b'?


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

2x9

42
New cards

What statement reverses vector a?


a = [1 2 3 4];

a(:,end:-1)

43
New cards

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

c = [7 ;8; 9]

44
New cards

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

whos

45
New cards

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

46
New cards

Which choice cannot add a directory to the search path?

the savepath function

47
New cards

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

grid

48
New cards

What is a key difference between && and &?

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

49
New cards

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

a 1x3 string array

50
New cards

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

You want to include optional input arguments.

51
New cards

What does e contain?


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

e = [0 1 8 9]

52
New cards

What does this function print?


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

: nothing will print

53
New cards

Which statement returns the character array 'alone'?


b = ['stand' 'alone'];

b(6:end)

54
New cards

What does b contain?


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

b = [1 6 8 9 19]

55
New cards

Which code shows the use of ellipsis in MATLAB?

A = [123; ... 567]

56
New cards

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

Real time user-defined memory allocation