![MATLAB MCQ Banner MATLAB MCQ Banner](https://static.placementpreparation.io/cdn-cgi/image/metadata=keep,quality=60,width=1440,height=500,f=auto,fit=cover/aptitude-images/aptitude/category/v2/webps/matlab-mcq-banner-web.webp)
Q31
Q31 What does the operator "*" do in MATLAB?
Matrix multiplication
Element-wise multiplication
Matrix addition
Matrix subtraction
Q32
Q32 Which operator performs element-wise multiplication?
.
./
.^
.*
Q33
Q33 What is the output of "5^2" in MATLAB?
10
25
5
Error
Q34
Q34 Which operator is used for logical AND in MATLAB?
&
&&
||
~
Q35
Q35 What is the result of "3 + 2 * 4" in MATLAB?
20
14
11
Error
Q36
Q36 What is the difference between "./" and "/" in MATLAB?
Both perform element-wise division
"./" is matrix division, "/" is element-wise division
"./" is element-wise division, "/" is matrix division
Both are matrix division
Q37
Q37 What is the result of "A .* B" for A = [1 2; 3 4], B = [2 0; 1 5]?
[2 0; 3 20]
[2 2; 3 5]
[2 0; 1 20]
[1 0; 3 5]
Q38
Q38 How do you calculate the transpose of a matrix "A" in MATLAB?
A'
transpose(A)
A
A.*A
Q39
Q39 How do you solve a system of linear equations Ax = b in MATLAB?
x = A\b
x = b\A
x = A/b
x = b/A
Q40
Q40 Why does "Matrix dimensions must agree" occur in MATLAB?
Different matrix sizes for an operation
Uninitialized variable
Unsupported operator
Incorrect syntax
Q41
Q41 What does the error "Inner matrix dimensions must agree" mean?
Unsupported operator
Matrix not initialized
Matrix sizes do not match for multiplication
Invalid operator
Q42
Q42 Why does "Invalid operator" occur in MATLAB?
Variable not initialized
Operator not supported for data type
Matrix is empty
All of the above
Q43
Q43 What is the purpose of an "if" statement in MATLAB?
To execute code conditionally
To define loops
To perform element-wise operations
To create matrices
Q44
Q44 Which keyword is used to terminate an "if" block in MATLAB?
endif
end
close
exit
Q45
Q45 What does a "for" loop do in MATLAB?
Executes code for each element in a sequence
Executes code while a condition is true
Executes code once
Defines a variable
Q46
Q46 What is the result of the following code?
for i = 1:3, disp(i); end
Error
1, 2, 3
3, 2, 1
Undefined behavior
Q47
Q47 How can you skip an iteration in a loop?
break
continue
exit
skip
Q48
Q48 Which keyword ends a "while" loop in MATLAB?
endwhile
close
end
break
Q49
Q49 Write a "for" loop to display numbers 1 to 5.
for i = 1:5, disp(i); end
for i = 1:5 disp(i)
disp(1:5)
for disp(1:5)
Q50
Q50 What does this code do?
for i = 2:2:6, disp(i); end
Displays even numbers
Displays odd numbers
Displays all numbers
Throws an error
Q51
Q51 Write a "while" loop that stops when x equals 10.
while x ~= 10, disp(x); x = x + 1; end
while x == 10, disp(x); x = x + 1; end
while x < 10 disp(x) end
for x = 1:10, disp(x); end
Q52
Q52 What error occurs if you omit "end" in a loop?
Syntax error
Unexpected MATLAB operator
Index exceeds matrix dimensions
Unbalanced or missing "end"
Q53
Q53 Why does "Index exceeds matrix dimensions" occur in a loop?
Incorrect index initialization
Index is out of bounds
Unsupported operator
Incorrect loop syntax
Q54
Q54 Why does "Infinite loop detected" occur?
Missing increment in loop
Unsupported condition
Loop not initialized
Syntax error
Q55
Q55 What is the primary purpose of functions in MATLAB?
To perform repetitive tasks
To store variables
To create plots
To manage memory
Q56
Q56 How do you define a function in MATLAB?
Using the "def" keyword
Using the "function" keyword
Using the "func" keyword
Using the "declare" keyword
Q57
Q57 What is the output of a function without a return statement?
Error
NaN
Default value
None
Q58
Q58 How can you call a function stored in another file?
Using the "import" command
By including the file in the same directory
Using "require"
It is not possible
Q59
Q59 What is the difference between scripts and functions?
Functions can have arguments, scripts cannot
Scripts are faster than functions
Functions cannot contain loops
Scripts cannot access variables
Q60
Q60 Write a function that returns the square of a number.
function y = square(x), y = x^2; end
function y = square(x), y = x^3; end
function y = square(x), y = sqrt(x); end
function square(x), disp(x^2); end