MCQs > IT & Programming > MATLAB MCQs > Basic MATLAB MCQs

Basic MATLAB MCQ

1. What is a reason to save a MAT-file using the -v7.3 flag?

Answer

Correct Answer: To include a variable greater that 2GB

Note: This Question is unanswered, help us to find answer for this one

2. 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?

Answer

Correct Answer: Which

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Whos

Note: This Question is unanswered, help us to find answer for this one

4. Which command will create a column vector with the values 7, 8, and 9?

Answer

Correct Answer: C = [7; 8; 9]

Note: This Question is unanswered, help us to find answer for this one

5. Which statement reverses vector a? A = [ 1 2 3 4];

Answer

Correct Answer: A(end:- 1:1)

Note: This Question is unanswered, help us to find answer for this one

6. What is the size of b? a = [1 2 3]; b = repmat(a,2,3);

Answer

Correct Answer: 2x9

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: 1:2:9

Note: This Question is unanswered, help us to find answer for this one

8. You've just plotted some data and want to change the color behind the lines you've plotted to black. Which code block will accomplish this?

Answer

Correct Answer: h_a = gca; set(h_a,'Color', [0 0 0]);

Note: This Question is unanswered, help us to find answer for this one

9. For a 5 x 5 array, the two subscript index (4,2) indexes the same location as linear index ___.

Answer

Correct Answer: 9

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: V = 1:10

Note: This Question is unanswered, help us to find answer for this one

11. 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;

Answer

Correct Answer: You are attempting to multiply a non-square matrix by itself, causing a dimension mismatch.

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Workspace

Note: This Question is unanswered, help us to find answer for this one

13. Which statement returns 1 (true)? a = 'stand' b = "stand"

Answer

Correct Answer: a == b

Note: This Question is unanswered, help us to find answer for this one

14. What kind of files are stored with the .mat extension?

Answer

Correct Answer: Stored variable files

Note: This Question is unanswered, help us to find answer for this one

15. Which is NOT a function that adds text to a plot?

Answer

Correct Answer: Label

Note: This Question is unanswered, help us to find answer for this one

16. Which statement creates a logical array that is 1 if the element in passwords contains a digit and 0 if it does not? Passwords = {'abcd' '1234' 'qwerty' 'love1'};

Answer

Correct Answer: Cellfun(@(x) ~isempty(regexp(x, '\d')), passwords)

Note: This Question is unanswered, help us to find answer for this one

17. Which statement using logical indices will result in an error? A = 1:10;

Answer

Correct Answer: B = a(a>6 && a<9)

Note: This Question is unanswered, help us to find answer for this one

18. Which statement is true about the sparse matrices?

Answer

Correct Answer: Sparse matrices always use less memory than their associated full matrices.

Note: This Question is unanswered, help us to find answer for this one

19. Which statement returns a cell array of the strings containing 'burger' from menu? Menu = {'hot dog' 'corn dog' 'regular burger' 'cheeseburger' 'veggie burger'}

Answer

Correct Answer: Menu(contains(menu, 'burger'))

Note: This Question is unanswered, help us to find answer for this one

20. 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 your height data?

Answer

Correct Answer: Sim_height = mean(height) + std(height) * randn(100, 1);

Note: This Question is unanswered, help us to find answer for this one

21. Which choice is the proper syntax to append a new elements a to the end of 1x 2 dimensional cell array C?

Answer

Correct Answer: C{end+1}=a

Note: This Question is unanswered, help us to find answer for this one

22. Which statement returns the roots for the polynomial x^2 + 2x - 4?

Answer

Correct Answer: Roots([1 2 -4])

Note: This Question is unanswered, help us to find answer for this one

23. Which choice adds b to each row of a? a = ones(4, 4); b= [1 2 3 4];

Answer

Correct Answer: A = a + repmat(b, 4, 1);

Note: This Question is unanswered, help us to find answer for this one

24. Which statement could create this cell array? c = {["hello world"]} {1×1 cell} {["goodbye"]} {1×3 double}

Answer

Correct Answer: c = {"hello world" {"hello"} "goodbye" [1 2 3]};

Note: This Question is unanswered, help us to find answer for this one

25. Which function CANNOT be used to randomly sample data?

Answer

Correct Answer: Resample

Note: This Question is unanswered, help us to find answer for this one

26. 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?

Answer

Correct Answer: Xticks(-3pi:pi:3pi)

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: S.name

Note: This Question is unanswered, help us to find answer for this one

28. You are in the middle of a long MATLAB session where you have performed many analyses and made many plots. You run the following commands, yet a figure window doesn't pop up on the top of your screen with your plot. What might be the issue? x = [-1:0.1:1]; y = X.^2; plot(x, y)

Answer

Correct Answer: Your plot is in a figure window that was already open, hidden behind other windows on your screen.

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: [0 1 1 1 2]

Note: This Question is unanswered, help us to find answer for this one

30. Which function could you use for multiple linear regression?

Answer

Correct Answer: Regress

Note: This Question is unanswered, help us to find answer for this one

31. What is the . character NOT used for?

Answer

Correct Answer: Cell array access

Note: This Question is unanswered, help us to find answer for this one

32. What is %% used for?

Answer

Correct Answer: Code sections

Note: This Question is unanswered, help us to find answer for this one

33. What does the Profiler track?

Answer

Correct Answer: Execution time

Note: This Question is unanswered, help us to find answer for this one

34. Based on the code below, c is the _ of a. a = rand(1, 11); b = sort(a); c = b(1, ceil(end/2));

Answer

Correct Answer: Median

Note: This Question is unanswered, help us to find answer for this one

35. From what distribution does the rand() function return value?

Answer

Correct Answer: Uniform

Note: This Question is unanswered, help us to find answer for this one