0% found this document useful (0 votes)
72 views

Matlab 0

MATLAB 0

Uploaded by

zairus gonzales
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views

Matlab 0

MATLAB 0

Uploaded by

zairus gonzales
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1. MATLAB stands for? 18.

Which is these is not an aspect of a for/while loop:


A. matrix laboratory A. update C. initialization
B. math library B. runner D. condition
C. matrix library 19. To better manage memory and prevent unnecessary memory allocations, Matlab uses:
D. matrix library A. vectors
2. Which command is used to clear a command window? B. matrix math
A. clear C. close all C. scalars
B. clc D. clear all D. delayed copy
3. To determine whether an input is a MATLAB keyword, command is? 20. To print a newline in a fprintf statement, you must use the following escape character:
A. iskeyword C. keyword A. \nl
B. inputword D. isvarname B. \t
4. Command used to display the value of variable x. C. \nxt
A. displayx C. disp(x) D. \n
B. disp x D. vardisp('x') 21. Which of the following will correctly define x, y, and z as symbols?
5. Command is used to save command window text to file. A. sym (x, y, z) C. syms x y z
A. saveas C. texttofile B. syms x, y, z D. sym x, y, z
B. diary D. todiary 22. Which of these is the way to access the first element in a vector named v (assuming there is at least one
6. Executing in the editor window the following code returns. element in the vector)?
a = 1; sin(a) a = 2; A. v(0) C. v(1)
A. 0.4815 B. v D. v(:, o)
B. 1 23. Which of the following is used to see if two elements are equal in MATLAB?
C. 0.8415 A. != C. ==
D. 0.9093 B. isequal D. =
7. To stop the execution of a MATLAB command, use keys? 24. If vector = [1 2 3 4; 11 24 92 100; 345 65 90 1]. What will the value of a be equal to if this code is entered
A. ctrl+c C. ctrl+s into MATLAB >>[a b] = size (vector)?
B. ctrl+b D. ctrl+enter A. 1234 C. 12
8. Which is the invalid variable name in MATLAB? B.4 D. 3
A. x6 C. last 25. 14. What is the value of ans that is printed when the following code is
B. 6x D. z run: isnumeric(32)
9. How to end the MATLAB software? A.1 C. o
A. Type "Exit" B. yes D. true
B. Type "End" 26. If I want to save a formatted string to memory, but don't want to print it out, which command should I use?
C. Type "ESC" A. fprintf
D. Another method is used B. disp
10. Which of the following is not a predefined variable in Matlab. C. sprintf
A. pi C. i D. echo
B. inf D. g 27. To add a comment to the mfile, the MATLAB command is
11. What is the storage in Matlab? A. % C. comment(**)
A. Decimal B. ; D. &
B. Character 28. When used in the fprintf command, the %9 is used as the
C. Array A. single character display C. string notation display
D. Numeric B. fixed point display D. default number display
12. In Matlab, this keyword immediately moves to the next iteration of the loop: 29. When used in the fprintf command, the \n is used to
A. update C. continue A. add a space between any two characters
B. goto D. break B. add a line space (enter key)
13. Characters in Matlab are represented in their value in memory. C. place a number into the comment
A. decimal C. ASCII D. clear the comment
B. hex D. string 30. To display 'Question 2' in the command window, the correct command is
14. Which is these is not an aspect of for/while loop: A. disp(Question 2) C. disp('Question 2')
A. condition C. update B. display('Question 2') D. Question 2
B. initialization D. runner 31. The cle command is used to
15. This Matlab command clears all data and variables stored in memory: A. clear the command window
A. clc C. delete B. erase everything in the mfile
B. clear D. deallocate C. clean the desktop
16. What symbol precedes all comments in Matlab? D. save the existing mfile
A.% C. II 32. The num2str command
B. < D. none of the above A. converts a number to string
17. This Matlab command clears all data and variables stored in memory: B. converts string to a number
A. cle C. clear C. concatenates numbers and strings
B. delete D. deallocate D. concatenates strings
33. To join one or more strings into a single string is known as 48. Which command is used to display the contents of a file in the MATLAB command window?
A. concatenation C. string conversion A. view
B. joining D. string theory B. show
34. The output of the last line is C. display
aa=2 D. load
as=num2str(aa) 49. How can you check the size of a matrix in MATLAB?
cat=['cat' as] A. size() C. dimensions()
A. cat2 B. length() D. shape()
B. cat 2 50. Which command is used to generate a sequence of evenly spaced values in MATLAB?
C. ??? Undefined function or variable 'as' A. linspace
D. cat aa B. sequence
35. The output of cat=['cat' 'dog'] is C. range
A. catdog D. generate
B. cat dog 51. What does the "disp" function do in MATLAB?
C. cat&dog A. Display the contents of a variable.
D. CatDog B. Calculate the exponential value.
36. How would you plot multiple graphs in MATLAB? C. Round a number to the nearest integer.
A. Using the hold function C. Using the mstem function D. Perform element-wise division.
B. Using the mplot function D. It cannot be done in MATLAB 52. Which command is used to calculate the dot product of two vectors in MATLAB?
37. How do you show the program of an MAT file? A. dot C. multiply
A. The program should contain the echo command B. product D. cross
B. The program should contain the showprog command 53. How do you access the element in the second row and third column of a matrix called "A" in MATLAB?
C. The program should contain the diary command A. A(2,3)
D. The program cannot be shown while running a MEX file B. A{2,3}
38. The help command works only for a pre-defined function in MATLAB. C. A[2][3]
I. True II. False D. A[2,3]
A. I only 54. Which command is used to find the maximum value in an array in MATLAB?
B. Both I & II A. max
C. II only B. largest
D. None of the above C. maximum
39. What is the equivalent of subplot (1, 1, 1)? D. peak
A. subplot() 55. What is the output of the following MATLAB code?
B. plot A = [1 2 3; 4 5 6; 7 8 9];
C. It is not possible B = A(:, 2);
D. axes disp(B);
40. It is not possible to store graphs as MAT-file. A. [2 5 8]
A. True B. False B. [1 2 3]
41. The command used to reflect the files from a disk into the workspace is C. [2; 5; 8]
A. load C. disp() D. [4 5 6]
B. show D. it is not possible 56. Index of an array in MATLAB start with
42. The format for 5 digit representation along with exponent is A. O
A. short e B. 1
B. short g C. Depends on the class of array
C. short exp D. Unknown
D. 4 digit along with exponent value can be represented 57. What is the return type of angles function in MATLAB?
43. Which operator is used to prevent the printing of insignificant zeros? A. Degrees C. Radians & Degrees
A. %0 C. %g B. Radians D. Depends on the argument
B. %nz D. It is not possible 58. What is use of abs function in Matlab?
44. The function to plot a graph with both axes on logarithmic scales is A. returns the square root of number
A. loglog C. semilog B. returns magnitude of a number
B. log D. not possible C. returns power of number
45. We cannot plot a discrete and continuous relationship in the same graph. D. None of these
A. True B. False 59. What will be the output of atan2(-1,1) in Matlab?
46. What is the command used to clear all variables from the workspace in MATLAB? A. Error C. 0.7854
A. clearvars B. pi/4 D. 0
B. clear 60. Which character is used to print new line in a fprintf statement?
C. delete A. \n C. \nml
D. remove B. \nl D. \nxt
47. Which MATLAB function is used to calculate the absolute value of a number? 61. What is output of A= [1 0 2]; b = [3 0 7]; c=a.*b;
A. abs C. ceil A. [2021] C. [1403]
B. round D. floor B. [3 0 14] D. [7 0 3]
62. Keys combition used to stop execution of a command in MATLAB? 76. Which code block contains the correct syntax for a while loop?
A. ctrl+c C. ctrl+b A.
B. ctrl+s D. ctrl+enter a= O;
63. Which class is used in Matlab to store the complex number? do
A. Double C. character a=a+1;
B. symbolic D. array while a< 5
64. Which of the following is a switch-case structure? End
A. Logical structure C. Hierarchical structure B.
B. Conditional structure D. Multidimensional structure a= O;
65. Which of the following is a Assignment operator in matlab? while(a < 5)
A. '+' a=a+1;
B. '=' C.
C. '*' a= O;
D. '$' while a< 5:
66. The continue statement exits the current iteration In nested loops. a=a+1;
I. True II. False D.
A. I only C. II only a= O;
B. Both I & II D. None of the above while a< 5
67. Which of the following is the disadvantage of Matlab? a=a+1;
A. Matlab is a fourth-generation high-level language end
B. Being compiler independent makes Matlab more efficient and productive 77. You have written a function myfun and want to measure how long it takes to run. Which code segment will
C. Matlab codes are written in sentences and executed one by one return in t the time in seconds it takes myfun to run?
D. Matlab is an interpreted language thus it can be very slow. A.
68. What are the features of Matlab? t = cputime(myfun());
A. Full Graphics Capabilities B.
B. Platform Independent tic; myfun(); toe;
C. Ease of Use & Good Source of Help C.
D. All of the above t = timer(myfun());
69. When was MATLAB 9.7 R2019b released? D.
A. May 2019 timer.start; myfun()
B. Sep 2019 t = timer.stop;
C. Aug 2019 78. Which function could you use for multiple linear regression?
D. July 2019 A. polyval C. solve
70. Which of the following command lists the current variable in Matlab? B. regress D. polyfit
A. Type C. Pwd 79. For which of these arrays do mean, median, and mode return the same value?
B. Who D. Date A. [O 1 1 1 2] C. [O 1 1 1 1]
71. From what distribution does the rand() function return value? B. [1 3 5 5 6] D. [O O 5 5 5]
A. normal C. poisson 80. How do you access the value for the field name in structure S?
B. binomial D. uniform A. S['name'] C. S('name')
72. Based on the code below, c is the __ of a. B. S.name D. S{'name'}
a = rand(1, 11); 81. What built-in definition does i have?
b = sort(a); A. basic imaginary unit
c = b(1, ceil(end/2)); B. index function
A. median C. infinity
B. mode D. index variable
C. mean 82. You are in the middle of a long MATLAB session where you have performed many analyses and made
D. margin many plots. You run the following commands, yet a figure window doesn't pop up on the top of your screen
73. What does the Profiler track? with your plot. What might be the issue?
A. execution time x = [-1:0.1:1];
B. errors y = X.A2;
C. command history plot(x, y)
D. the value of variables A. Your plot doesn't plot in a figure window because figure was not called immediately in advance.
74. What is%% used for? B. Your plot syntax is incorrect.
A. argument placeholder C. Your plot is in a figure window that was already open, hidden behind other windows on your
B. block quotes screen.
C. code sections D. Your plot was saved to an image file but not displayed.
D. conversion specifier 83. Which statement is equivalent to this for loop?
75. What is the . character NOT used for? a = [1 2 3; 4 5 6];
A. structure field access b = zeros(size(a));
B. a decimal point for i_row = 1:size(a, 1)
for i_col = 1:size(a, 2)
C. cell array access b(i_row, i_col) = a(i_row, i_col)^2;
D. element-wise operations
end C. sim_height = randn(std (height), mean (height), [100, 11);
end D. sim_height = randn(mean(height), std (height), [100, 11);
A. b = a*a; 95. Which statement returns a cell array of the strings containing_burger' from menu?
B. b = a.A2; menu = {'hot dog' 'corn dog' 'regular burger' 'cheeseburger' 'veggie burger'}
C. b = aA2; A. menu{strfind(menu, 'burger')}
D. b = pow2(a); B. menu(strfind(menu, 'burger'))
84. You have plotted values of cosine from -10 to 10 and want to change the x-axis tick marks to every pi, C. menu{contains(menu, 'burger')}
from -3pi to 3pi. Which statement will do that? D. menu(contains(menu, 'burger'))
A. xticks(-3pi:3.14:3pi) 96. Which statement is true about the sparse matrices?
B. xticks(-3pi:pi:3pi) A. You can use the sparse function to remove empty cells from cell array variables.
C. xticks(linespace(-3pi(), 3pi(), pi())) B. Sparse matrices always use less memory than their associated full matrices.
D. xticks(linespace(-3pi, 3pi, pi) C. Mixtures of sparse and full matrices can be combined in all of MATLAB's built-in arithmetic
85. Which function CANNOT be used to randomly sample data? operations.
A. datasample C. resample D. The sparse function requires its input to be a full matrix with at least 50% zero elements.
B. randi D. randperm 97. What is the set of possible values that a may contain?
86. What is the value of c? a = randi(10, [1, 10]);
a = ones(1,3); a(3) = 11;
b = 1:3; a(a>2) = 12;
c = conv(a,b) A. 3,4, 5,6, 7,8,9, 10, 11, 12
A. [-1 2 -1] B. 1, 2, 12
B. [1 3 6 5 3] C. 2,11,12
C. 6 D. 1, 12
D. [1-21] 98. Which statement creates a logical array that is 1 if the element in passwords contains a digit and O if it
87. Which function CANNOT be used to randomly sample data? does not?
A. datasample C. resample passwords = {'abed '1234' qwerty' 'love!'};
B. randi D. randperm A. contains(password, '\d')
88. What is true of a handle class object? B. ~isempty(regexp(passwords, '\d'))
A. When you pass a handle object to a function, a new object is made that is independent of the C. cellfun(@(x) ~isempty(regexp(x, '\d')), passwords)
original. D. regexp(passwords, '\d')
B. All copies of handle objects refer to the same underlying object. 99. Which is NOT a function that adds text to a plot?
C. Handle object cannot reference one another. A. title C. label
D. Handle object do not have a default eq function. B. text D. legend
89. Which choice will NOT give you a 5 x 5 identity matrix? 100. What kind of files are stored with the .mat extension?
A. a = rand(5); round (a* inv(a)) A. figure files C. function files
B. diag(ones (5, 1)) B. script files D. stored variable files
1. A 26. C 51. A 76. D
C. identity(5)
D. eye (5) 2. B 27. A 52. A 77. B
90. Which statement could create this cell array?? 3. A 28. D 53. A 78. B
C = {["hello world"]} {1x1 cell} {["goodbye"]} {1x3 double} 4. C 29. B 54. A 79. A
A. c={"hello world" ("hello") "goodbye" [1 2]}; 5. B 30. C 55. A 80. B
B. c = {"hello world" ("hello") "goodbye" {[1 2 3]}}; 81. A
6. C 31. A 56. B
C. c={"hello world" ("hello") "goodbye" [1 2 31};
7. A 32. A 57. B 82. C
D. c={"hello world" ("hello" "hello") "goodbye" ([1 2 3]}};
91. Which choice is the proper syntax to append a new elements a to the end of 1x 2 dimensional cell array C? 8. B 33. A 58. B 83. B
A. C ={Ca}; 9. A 34. A 59. C 84. B
B. C= cellcat(Ca) 10. D 35. A 60. A 85. C
C. C=cat(2, (a), C) 11. C 36. A 61. B 86. B
D. C(end+1)=a 37. D 62. A 87. C
12. C
92. Which choice adds b to each row of a? a= ones (4, 4); 88. B
b= [1 2 3 4]; 13. C 38. A 63. B
A. a = a + reshape(b, 4, 1); 14. D 39. D 64. A 89. C
B. a= a+ b'; 15. B 40. A 65. B 90. C
C. a= a+ repmat(b, 4, 1); 16. D 41. A 66. A 91. D
D. a = a + [b b b b]; 17. C 42. A 67. D 92. C
93. Which statement returns the roots for the polynomial x"2 + 2x - 4? 43. C 68. D 93. D
18. B
A. poly([1 2 -4]) C. polyfit(x"2+2x-4 == 0) 94. B
19. D 44. A 69. B
B. solve(x"2+2x-4 == 0) D. roots([1 2 -41)
20. D 45. B 70. B 95. D
94. You have loaded a dataset of people's heights into a 100 x 1 array called height. Which statement will
return a 100 x 1 array, sim height, with values from a normal distribution with the same mean and variance as 21. C 46. A 71. D 96. B
your height data? 22. C 47. A 72. A 97. B
A. sim_height = std (height)+ mean(height) randn(100, 1); 23. C 48. D 73. A 98. C
B. sim_height = mean(height) + std(height) randn(100, 1); 24. D 49. A 74. C 99. C
25. D 50. A 75. C 100. D

You might also like