Which of the following is a valid variable name in MATLAB? a) 1stVar b) Var_1 c) _Var d) 1_var
In MATLAB, variable names must begin with which of the following characters? a) A number b) A letter c) A symbol d) A whitespace
What is the maximum length of a variable name in MATLAB? a) 50 characters b) 63 characters c) 128 characters d) 100 characters
Which of the following is a valid example of a MATLAB variable? a) 4Var b) Var_4 c) Var! d) Var(4)
MATLAB is case-sensitive. Which of the following are considered different variables? a) var and Var b) var_ and var c) _var and var d) None of the above
Scalars, Vectors, and Matrices
A scalar in MATLAB is: a) A single value of any type b) A one-dimensional array c) A two-dimensional array d) A matrix
Which of the following MATLAB code defines a vector? a) v = [1, 2, 3] b) v = (1; 2; 3) c) v = {1, 2, 3} d) v = [1; 2; 3]
How would you create a 3×3 identity matrix in MATLAB? a) I = zeros(3, 3) b) I = eye(3) c) I = ones(3, 3) d) I = diag(3)
What is the result of the following MATLAB operation: A = [1, 2; 3, 4]; B = [5, 6; 7, 8]; C = A * B? a) [19, 22; 43, 50] b) [23, 34; 67, 89] c) [19, 22; 43, 50] d) Error due to incompatible matrix sizes
Which MATLAB command would you use to find the transpose of a matrix? a) transpose() b) inv() c) flip() d) .’
Common Data Types (double, char, logical)
What is the default numeric data type in MATLAB? a) integer b) char c) double d) logical
What does the MATLAB command char('a') return? a) 97 b) ‘a’ c) 1 d) Error
The MATLAB command logical(1) returns: a) true b) false c) 1 d) 0
Which of the following is a logical expression in MATLAB? a) x == 5 b) x = 5 c) x + 5 d) x >
What is the result of the following MATLAB operation: x = true; y = false; z = x & y? a) true b) false c) 1 d) Error
Type Conversion
Which MATLAB function converts a string to a double-precision value? a) int2str() b) str2num() c) double() d) num2str()
What is the MATLAB command to convert a number to a character? a) num2char() b) num2str() c) str2char() d) char2num()
Which of the following converts a number to a logical value in MATLAB? a) logical() b) str2double() c) double() d) num2log()
If x = 10, which of the following commands will convert x to a string? a) num2char(x) b) char(x) c) str(x) d) num2str(x)
What is the output of the following MATLAB code: y = double('3.14')? a) 3.14 b) 51.14 c) 51 d) Error
Additional Questions
What does the function isempty(x) do in MATLAB? a) Returns true if x is empty b) Converts x to an empty array c) Checks if x is a scalar d) Returns false if x is empty
How do you create a logical array of size 3×3 with all elements set to true? a) true(3, 3) b) ones(3, 3) c) zeros(3, 3) d) logical(3, 3)
Which function is used to check the type of a variable in MATLAB? a) varType() b) type() c) class() d) check()
What will the expression size([1, 2; 3, 4]) return? a) 1 b) 2 c) [2, 2] d) [1, 4]
What MATLAB function is used to create a matrix of all zeros? a) ones() b) zeros() c) eye() d) rand()
In MATLAB, which of the following represents a 2×3 matrix? a) [1 2 3; 4 5 6] b) [1 2; 3 4] c) [1 2 3; 4 5] d) [1 2 3]
What is the result of the operation size([1, 2, 3]) in MATLAB? a) [1, 3] b) [3, 1] c) [1, 1] d) Error
Which function converts an integer value to a string in MATLAB? a) int2str() b) num2str() c) str2num() d) string()
How do you check if a matrix is square in MATLAB? a) size(A) == size(B) b) ismatrix(A) c) all(size(A) == size(B)) d) size(A, 1) == size(A, 2)
What will be the output of the MATLAB code class(3.5)? a) ‘double’ b) ‘int32’ c) ‘single’ d) ‘char’