MATLAB MCQ Banner

MATLAB Multiple Choice Questions (MCQs) and Answers

Master MATLAB with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of MATLAB. Begin your placement preparation journey now!

Q61

Q61 How can you pass multiple arguments to a function?

A

function result = myFunc(arg1, arg2)

B

function myFunc(arg1, arg2)

C

function result = myFunc[arg1, arg2]

D

function myFunc(arg1 arg2)

Q62

Q62 Create a function to calculate the factorial of a number.

A

function f = fact(n), if n == 0, f = 1; else, f = n * fact(n-1); end; end

B

function f = fact(n), f = n * fact(n+1); end

C

function f = fact(n), f = n^2; end

D

function fact(n), disp(factorial(n)); end

Q63

Q63 What happens if a function name and a variable name conflict?

A

Error

B

Variable is ignored

C

Function is ignored

D

Unexpected behavior

Q64

Q64 Why does "Too many input arguments" occur?

A

Passing fewer arguments than required

B

Passing more arguments than defined

C

Using undefined variables

D

Function name conflict

Q65

Q65 Why does "Not enough input arguments" occur?

A

Missing input values in the function call

B

Incorrect function definition

C

Conflicting variable names

D

Undefined function

Q66

Q66 Which function is used to create a basic 2D plot?

A

graph()

B

plot()

C

plot2D()

D

chart()

Q67

Q67 What does the "title()" function do in MATLAB?

A

Adds a title to a plot

B

Adds a legend to a plot

C

Adds a label to the axes

D

Creates a subplot

Q68

Q68 How do you label the x-axis of a plot?

A

xlabel("label")

B

ylabel("label")

C

axislabel("label")

D

xaxis("label")

Q69

Q69 What is the purpose of the "legend()" function?

A

Adds a legend to a plot

B

Adds a title to a plot

C

Creates a new figure

D

Sets the axis limits

Q70

Q70 Which function is used for creating a 3D surface plot?

A

meshgrid()

B

surf()

C

surface3D()

D

plot3D()

Q71

Q71 Write a code snippet to plot a sine wave.

A

x = 0:0.1:10; y = sin(x); plot(x, y);

B

x = linspace(0, 10, 100); y = cos(x); plot(y, x);

C

x = 0:0.1:10; y = cos(x); plot(x, y);

D

x = 1:0.1:10; y = sin(x); plot(y, x);

Q72

Q72 How do you plot multiple lines on the same graph?

A

plot(x1, y1, x2, y2)

B

multiplot(x1, y1, x2, y2)

C

lines(x1, y1, x2, y2)

D

plotlines(x1, y1, x2, y2)

Q73

Q73 Write a MATLAB code to create a bar chart.

A

bar(x, y)

B

barchart(x, y)

C

plotbar(x, y)

D

chartbar(x, y)

Q74

Q74 Write a MATLAB code snippet to create a 3D plot of z = x^2 + y^2.

A

[x, y] = meshgrid(-10:1:10); z = x.^2 + y.^2; surf(x, y, z);

B

[x, y] = meshgrid(-10:1:10); z = x^2 + y^2; plot(x, y, z);

C

[x, y] = meshgrid(-10:1:10); z = x + y; surf(x, y, z);

D

[x, y] = meshgrid(-10:1:10); z = x.^2 + y.^2; plot(x, y, z);

Q75

Q75 Why does "Index exceeds matrix dimensions" occur when plotting?

A

Incorrect axis limits

B

Matrix size mismatch

C

Undefined variable

D

Incorrect syntax

Q76

Q76 What causes "Invalid color specification" in MATLAB?

A

Undefined variable

B

Unsupported color format

C

Missing semicolon

D

Incorrect axis label

Q77

Q77 Why does "Array dimensions do not match" occur in a plot?

A

Missing function argument

B

Array sizes are incompatible

C

Undefined function

D

Matrix is empty

Q78

Q78 What does the "zeros" function do in MATLAB?

A

Creates an array of zeros

B

Initializes variables to zero

C

Generates random zeros

D

None of the above

Q79

Q79 How do you create a 3x3 identity matrix in MATLAB?

A

identity(3)

B

eye(3)

C

ones(3)

D

diag(3)

Q80

Q80 Which function returns the size of a matrix?

A

length()

B

size()

C

dim()

D

rows()

Q81

Q81 What does "diag" function do in MATLAB?

A

Creates a diagonal matrix

B

Finds the determinant

C

Returns the trace

D

Transposes a matrix

Q82

Q82 How do you access the last element of a matrix "A"?

A

A(end)

B

A(last)

C

A(size(A))

D

A(-1)

Q83

Q83 Write a MATLAB command to create a row vector from 1 to 10.

A

1:10

B

[1,10]

C

linspace(1,10,10)

D

ones(1,10)

Q84

Q84 How do you transpose a matrix "A" in MATLAB?

A

transpose(A)

B

A'

C

flip(A)

D

inv(A)

Q85

Q85 Write a MATLAB command to create a 2x2 matrix with random values.

A

rand(2)

B

random(2)

C

randmatrix(2)

D

rand2(2)

Q86

Q86 Write a MATLAB code snippet to calculate the inverse of a matrix "A".

A

inv(A)

B

inverse(A)

C

A^-1

D

1/A

Q87

Q87 Why does "Index exceeds matrix dimensions" occur in MATLAB?

A

Accessing an element outside the matrix size

B

Matrix is not initialized

C

Matrix contains invalid data

D

Incorrect syntax

Q88

Q88 Why does "Singular matrix" error occur when inverting a matrix?

A

Matrix is not square

B

Matrix determinant is zero

C

Matrix dimensions do not match

D

Matrix contains NaN

Q89

Q89 What causes "Matrix dimensions must agree" in element-wise operations?

A

Mismatched dimensions

B

Unsupported operator

C

Empty matrix

D

NaN values

Q90

Q90 Which function is used to save variables to a file in MATLAB?

A

save()

B

write()

C

store()

D

export()

ad verticalad vertical
ad