InterviewPitch

Land the job you want — prepare
with Real interviews Q&A

Curated interview questions, company-wise guides and coding rounds. Practice mock interviews, improve with feedback, and track your progress.

Q&A
Top curated interview packs
Company-wise & role-wise packs, quality assured.
Start a quiz
Instant scoring
All Interview Q&A
50 plus topics
Beginner
1. What is MATLAB?

MATLAB (Matrix Laboratory) is a high-level programming language and interactive environment developed by MathWorks. It is widely used for numerical computing, matrix manipulations, data analysis, visualization, and algorithm development.

Beginner
2. What are MATLAB variables?

Variables in MATLAB are used to store data values. They are dynamically typed, which means you do not need to explicitly declare their data type or allocate memory before using them.

Beginner
3. What is a matrix in MATLAB?

A matrix is the fundamental data structure in MATLAB. MATLAB is designed to treat all variables as multi-dimensional arrays or matrices, which allows for highly optimized mathematical operations.

Beginner
4. How do you create a row vector?

A row vector can be created by separating element values with spaces or commas inside square brackets:

MATLAB
a = [1 2 3 4];
Beginner
5. How do you create a column vector?

A column vector is created by separating element values with semicolons inside square brackets:

MATLAB
a = [1; 2; 3; 4];
Beginner
6. What is the use of semicolon (;) in MATLAB?

Placing a semicolon (;) at the end of a line suppresses output display in the Command Window, allowing statements to execute quietly in the background.

Beginner
7. How do you write comments in MATLAB?

Comments are initiated with the percent symbol (%). Anything following it on the same line is ignored by the compiler:

MATLAB
% This is a single-line comment in MATLAB
Intermediate
8. What is a script in MATLAB?

A script is a standard text file with a .m extension containing a sequential list of MATLAB commands. Running the script executes these statements as if they were typed directly into the command line.

Intermediate
9. What is a function in MATLAB?

A function is a separate block of code that accepts parameters, runs isolated computations in its own workspace, and returns specific output variables.

Intermediate
10. Difference between script and function?

Scripts operate within the global base workspace, sharing variable declarations directly.Functions maintain an isolated, temporary local workspace that clears automatically when execution ends.

Intermediate
11. How do you create a function?

Functions are declared using the function keyword, mapping outputs, the function name, and inputs:

MATLAB
function y = squareNum(x)
    y = x^2;
end
Intermediate
12. What is indexing in MATLAB?

Indexing refers to accessing individual elements or sub-sections of arrays and matrices. MATLAB uses 1-based indexing, meaning the first element in any array starts at index 1.

Intermediate
13. What is the colon operator?

The colon operator (:) generates sequences of values and is useful for creating loops or slicing index matrices:

MATLAB
% Generate sequence from 1 to 5
seq = 1:5;
Intermediate
14. What is a cell array?

A cell array is a dynamic database structure containing indexed buckets called cells, where each individual cell can store different data types, structures, and dimensions.

Intermediate
15. What is a structure in MATLAB?

Structures group data logically using named parameter fields, letting you map associated attributes to a single object:

MATLAB
person.name = 'John';
person.age = 30;
Advanced
16. What is vectorization in MATLAB?

Vectorization is the process of replacing explicit loops (like for and while) with matrix algebra equations. Since MATLAB operations are highly optimized for matrices, vectorized code runs significantly faster.

Advanced
17. What is handle vs value class?

A Value class creates a completely new copy of an object when it is assigned or passed to a function. A Handle class passes objects by reference, meaning modifications in one location affect all variables referencing that instance.

Advanced
18. What is a sparse matrix?

A sparse matrix is an optimized matrix structure that only stores elements with non-zero values. This saves memory and calculation overhead when working with large matrices containing mostly zeroes.

Advanced
19. What is Simulink?

Simulink is a block-diagram, visual programming environment integrated directly with MATLAB. It is used for modeling, simulating, and analyzing multi-domain dynamic and embedded control systems.

Advanced
20. What is a MEX file?

A MEX file (MATLAB Executable) is a compiled C, C++, or Fortran subroutine that runs directly inside MATLAB, allowing you to optimize computationally heavy tasks.

Coding Round
41. Find factorial using loop
MATLAB
n = 5;
fact = 1;
for i = 1:n
    fact = fact * i;
end
Coding Round
42. Reverse a vector
MATLAB
a = [1 2 3 4];
rev = fliplr(a);
Coding Round
43. Check prime number
MATLAB
n = 7;
is_prime_result = isprime(n);
Coding Round
44. Sum of array elements
MATLAB
a = [1 2 3 4];
s = sum(a);
Coding Round
45. Find maximum element
MATLAB
a = [1 12 3 4];
maxVal = max(a);
Coding Round
46. Transpose matrix
MATLAB
A = [1 2; 3 4];
B = A';
Coding Round
47. Plot a sine wave
MATLAB
x = 0:0.1:2*pi;
y = sin(x);
plot(x, y);
Coding Round
48. Create identity matrix
MATLAB
I = eye(3);
Coding Round
49. Find length of string
MATLAB
str = 'Hello';
len = length(str);
Coding Round
50. Swap two numbers
MATLAB
a = 5;
b = 10;
temp = a;
a = b;
b = temp;