Matlab Built-in Functions Quiz

Matlab
0 Passed
0% acceptance

40 comprehensive questions on MATLAB's built-in functions covering mathematical operations, statistical computations, NaN/Inf handling, and data validation functions — with 16 code examples to master MATLAB's cpp quiz computational capabilities.

40 Questions
~80 minutes
1

Question 1

What is the basic trigonometric function for sine in MATLAB?

A
sin() function computes the sine of angle values in radians for trigonometric calculations
B
sine() function for sine calculations
C
trig_sin() for trigonometric sine
D
Sine is not supported
2

Question 2

How do you compute the square root of a number in MATLAB?

matlab
result = sqrt(16);
A
Use sqrt() function to calculate the square root of positive real numbers and complex numbers
B
sqrt() only works for perfect squares
C
Use root() function for square roots
D
Square root is not supported
3

Question 3

What does the exp function do?

matlab
result = exp(1);
A
exp() computes e raised to the power of the input, providing exponential function calculations
B
exp() calculates natural logarithm
C
exp() is for integer exponents only
D
Exponential functions are not supported
4

Question 4

How do you calculate the natural logarithm in MATLAB?

matlab
result = log(2.718);
A
Use log() function to compute the natural logarithm (base e) of positive real numbers
B
log() calculates common logarithm (base 10)
C
Use ln() for natural logarithm
D
Natural logarithm is not supported
5

Question 5

What is the purpose of the abs function?

matlab
result = abs(-5);
A
abs() computes the absolute value of real numbers and magnitude of complex numbers
B
abs() calculates square root
C
abs() is for string operations
D
Absolute value is not supported
6

Question 6

How do you compute the mean of an array?

matlab
data = [1, 2, 3, 4, 5];
avg = mean(data);
A
Use mean() function to calculate the arithmetic average of array elements along specified dimensions
B
mean() calculates median value
C
Use average() for mean calculation
D
Mean calculation is not supported
7

Question 7

What does the std function compute?

matlab
data = [1, 2, 3, 4, 5];
s = std(data);
A
std() calculates the standard deviation measuring data spread around the mean for statistical analysis
B
std() computes variance
C
std() finds minimum value
D
Standard deviation is not supported
8

Question 8

How do you find the minimum value in an array?

matlab
data = [5, 2, 8, 1, 9];
min_val = min(data);
A
Use min() function to find the smallest element in an array or minimum along specified dimensions
B
min() calculates mean value
C
Use minimum() for min calculation
D
Minimum finding is not supported
9

Question 9

What is the isnan function used for?

matlab
result = isnan([1, NaN, 3]);
A
isnan() detects Not-a-Number values in arrays, returning logical array indicating NaN locations for data validation
B
isnan() checks for infinite values
C
isnan() tests for empty arrays
D
NaN detection is not supported
10

Question 10

How do you check if a value is infinite?

matlab
result = isinf([1, Inf, -Inf, 3]);
A
Use isinf() function to detect positive and negative infinity values in numerical data
B
isinf() checks for NaN values
C
isinf() tests for zero values
D
Infinity detection is not supported
11

Question 11

What does the isempty function check?

matlab
result = isempty([]);
A
isempty() determines if an array or variable contains no elements, useful for conditional processing and data validation
B
isempty() checks for zero values
C
isempty() tests for NaN values
D
Empty checking is not supported
12

Question 12

How do you check if a variable is numeric?

matlab
result = isnumeric(42);
A
Use isnumeric() function to verify if a variable contains numeric data types for type validation
B
isnumeric() checks for string data
C
isnumeric() tests for logical values
D
Numeric type checking is not supported
13

Question 13

What is the round function used for?

matlab
result = round(3.7);
A
round() rounds numbers to the nearest integer using standard rounding rules for numerical precision control
B
round() always rounds up
C
round() calculates square root
D
Rounding is not supported
14

Question 14

How do you compute the sum of array elements?

matlab
data = [1, 2, 3, 4, 5];
total = sum(data);
A
Use sum() function to calculate the total of array elements along specified dimensions for aggregation operations
B
sum() calculates product
C
Use total() for summation
D
Summation is not supported
15

Question 15

What does the length function return?

matlab
arr = [1, 2, 3, 4, 5];
len = length(arr);
A
length() returns the number of elements in a vector or the largest dimension size of a matrix for array sizing information
B
length() calculates array sum
C
length() finds maximum value
D
Length calculation is not supported
16

Question 16

How do you find the median of data?

matlab
data = [1, 3, 5, 7, 9];
med = median(data);
A
Use median() function to find the middle value in sorted data, providing robust central tendency measure less sensitive to outliers than mean
B
median() calculates mean value
C
Use middle() for median calculation
D
Median calculation is not supported
17

Question 17

What is the difference between log and log10 functions?

A
log() computes natural logarithm (base e), log10() calculates common logarithm (base 10) for different logarithmic scales
B
They are identical functions
C
log10() is for natural logarithm
D
Only log() is supported
18

Question 18

How do you handle NaN values in statistical calculations?

A
Use nanmean(), nanstd(), nanmedian() functions that automatically ignore NaN values in statistical computations for robust data analysis
B
Remove NaN values manually before calculations
C
NaN values break statistical functions
D
NaN handling is not supported
19

Question 19

What does the fix function do?

A
fix() rounds numbers towards zero, truncating decimal parts for integer conversion without rounding
B
fix() rounds to nearest integer
C
fix() calculates square root
D
Fix function is not supported
20

Question 20

How do you compute the variance of data?

A
Use var() function to calculate data variance measuring squared deviations from mean for dispersion analysis
B
var() calculates standard deviation
C
Use variance() for variance calculation
D
Variance calculation is not supported
21

Question 21

What is the purpose of the rem function?

A
rem() computes the remainder of division (modulo operation) between two numbers for cyclic and periodic calculations
B
rem() calculates quotient
C
rem() finds square root
D
Remainder calculation is not supported
22

Question 22

How do you find the maximum value and its index?

A
Use [max_val, idx] = max(array) to get both maximum value and its position index for complete extreme value analysis
B
max() only returns the value
C
Use maximum() for max and index
D
Index finding is not supported
23

Question 23

What does the sign function return?

A
sign() returns -1 for negative numbers, 0 for zero, and 1 for positive numbers, indicating number sign for conditional logic
B
sign() calculates absolute value
C
sign() finds square root
D
Sign determination is not supported
24

Question 24

How do you compute the product of array elements?

A
Use prod() function to calculate the product of array elements along specified dimensions for multiplicative aggregation
B
prod() calculates sum
C
Use product() for product calculation
D
Product calculation is not supported
25

Question 25

What is the difference between floor and ceil functions?

A
floor() rounds down to nearest integer, ceil() rounds up to nearest integer for different rounding directions in numerical processing
B
They are identical functions
C
floor() rounds up, ceil() rounds down
D
Only floor() is supported
26

Question 26

How do you handle division by zero in MATLAB?

A
MATLAB returns Inf for division by zero, which can be detected using isinf() for proper error handling in computations
B
Division by zero causes program crash
C
Division by zero returns zero
D
Division by zero is not handled
27

Question 27

What does the mod function do?

A
mod() computes modulo operation with same sign as divisor, providing cyclic arithmetic for periodic calculations
B
mod() is identical to rem()
C
mod() calculates remainder with positive sign
D
Modulo operation is not supported
28

Question 28

How do you compute cumulative sum?

A
Use cumsum() function to calculate running totals of array elements for cumulative analysis and trend identification
B
cumsum() calculates cumulative product
C
Use running_sum() for cumulative sum
D
Cumulative operations are not supported
29

Question 29

What is the purpose of the rand function?

A
rand() generates uniformly distributed random numbers between 0 and 1 for simulations and stochastic analysis
B
rand() generates integers only
C
rand() creates random strings
D
Random number generation is not supported
30

Question 30

How do you find unique values in an array?

A
Use unique() function to extract distinct values from array, useful for categorical data analysis and duplicate removal
B
unique() sorts the array
C
unique() finds maximum value
D
Unique value extraction is not supported
31

Question 31

What does the sort function do?

A
sort() arranges array elements in ascending or descending order for data organization and ranking analysis
B
sort() finds unique values
C
sort() calculates mean
D
Sorting is not supported
32

Question 32

How do you compute the correlation coefficient?

A
Use corr() function to calculate correlation coefficients measuring linear relationship strength between variables for statistical analysis
B
corr() calculates covariance
C
Use correlation() for correlation coefficient
D
Correlation calculation is not supported
33

Question 33

What is the difference between var and std?

A
var() computes variance (squared standard deviation), std() calculates standard deviation (square root of variance) for different dispersion measures
B
They are identical functions
C
var() is for vectors, std() for matrices
D
Only std() is supported
34

Question 34

How do you compute matrix determinant?

A
Use det() function to calculate matrix determinant, providing information about matrix properties and linear system solvability
B
det() calculates matrix trace
C
Use determinant() for matrix determinant
D
Matrix determinant is not supported
35

Question 35

What does the norm function compute?

A
norm() calculates vector or matrix norm measuring magnitude or size using various norms (1, 2, inf, Frobenius) for mathematical analysis
B
norm() normalizes data
C
norm() calculates mean
D
Norm calculation is not supported
36

Question 36

How do you compute matrix inverse?

A
Use inv() function to calculate matrix inverse for solving linear systems and matrix equations
B
inv() calculates determinant
C
Use inverse() for matrix inverse
D
Matrix inverse is not supported
37

Question 37

What is the purpose of the find function?

A
find() locates indices of non-zero elements or elements meeting conditions for data filtering and conditional analysis
B
find() searches for values
C
find() calculates positions
D
Find function is not supported
38

Question 38

How do you compute the size of an array?

A
Use size() function to get dimensions of array as vector or specific dimension sizes for array structure analysis
B
size() calculates number of elements
C
size() finds memory usage
D
Size calculation is not supported
39

Question 39

What does the diff function do?

A
diff() computes differences between adjacent elements for derivative approximation and change detection in data sequences
B
diff() finds unique values
C
diff() calculates differences from mean
D
Difference calculation is not supported
40

Question 40

Considering MATLAB's built-in function ecosystem as a whole, what fundamental advantage does it provide compared to implementing mathematical operations from scratch?

A
Comprehensive optimized function library provides reliable, numerically stable implementations of complex mathematical operations with proper error handling, special case management, and computational efficiency that would require extensive expertise and testing to replicate manually
B
Faster execution speed only
C
Automatic code generation
D
Built-in documentation

QUIZZES IN Matlab