0% found this document useful (0 votes)
66 views

Matlab Interview Questions

Uploaded by

kamran ashraf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Matlab Interview Questions

Uploaded by

kamran ashraf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1) What is MATLAB?

MATLAB is a high-performance language for numerical computing. It consolidates


calculations, visualization, and programming in an easy-to-use environment where
problems and answers are expressed in familiar binary notation.
It contains:
o Math and computation
o Algorithm development
o Modeling, simulation, and prototyping
o Data analysis, exploration, and visualization
o Scientific and engineering graphics
o Application development, containing Graphical User Interface building

2) Explain MATLAB API (Application Program Interface)?


MATLAB API is a library that allows us to write Fortran and C programs that interact with
MATLAB. It includes the facilities for calling routines from MATLAB, for reading and
writing Mat files and calling MATLAB as a computational engine.

3) What is The MATLAB working environment?


This is the set of tools and facilities that we work with as the MATLAB client or
programmer. It contains facilities for managing the variables in our workspace and
importing and exporting data. It also contains tools for developing, managing,
debugging, and profiling M-files, MATLAB?s applications.

4) What is Simulink?
Simulink is an add-on product to MATLAB, it provides an interactive, simulating,
graphical environment for modeling and analyzing dynamic systems.

5) Explain how polynomials can be represented in MATLAB?


A polynomial in MATLAB is indicated by a vector. To create a polynomial in MATLAB,
enter each coefficient of the polynomial into the vector in descending order.

6) Explain handle graphics in MATLAB?


This is the MATLAB graphic system. It contains high-level commands for two-
dimensional and three-dimensional data visualization, image processing, animation, and
display graphics. It also contains low-level commands that allow us to customize the
display of graphics fully as well as to build complete Graphical User Interfaces on your
applications.
7) What is Get and Set in MATLAB?
Get and Set are indicated to as getter and setter functions. For assigning properties,
setter functions are used while for accessing features, getter functions are used.

8) Can Multi-dimensional arrays support in MATLAB?


No, it does not support. It supports the two-dimensional type of matrix. An option is an
option with the programmer to write the function of their own to utilize multi-
dimensional array features as per the application of use.

9) What are the types of Loops does MATLAB provides?


MATLAB provides loops like
o While Loop
o For Loop
o Nested Loops

10) What is 3D-Visualization elements in MATLAB?


3D-Visualization elements allow MATLAB to handle 3D graphics.
o Surface and Mesh Plots: It includes plot matrices, visualizes functions, and color
maps.
o View Control: It is used to control camera viewpoint, rotation, zooming, and
aspect ratio and set axis limits.
o Lighting: It is used for adding and controlling scene lighting.
o Transparency: It is used to specify object transparency.
o Volume Visualization: It is used for the volume data grid.

11) What is memory management functions in MATLAB?


Following are the lists of memory management functions.
o Clear: It removes variables from memory.
o Pack: It saves the existing variables to disk, and then reloads them contiguously.
o Save: It selectively persists variable to disk.
o Load: Reloads a data file stored with the save function.
o Quit: Exits MATLAB and all allocated memory to the system.

12) What are the basic Plots and Graphs of MATLAB?


Following table defines basic plots and graphs:
o Box: Axis Border
o Errorbar: Plots error bars along the curve.
o Hold: Retains the current graph while adding a new graph.
o Line: Creates a line object.
o LineSpec (Line Specification): Syntax of Line Specification String.
o Loglog: Log to the log-scale plot.
o Plot: 2-D Line Plot.
o Plot3: 3-D Line Plot.
o Plotyy: 2-D Line plots with y-axis on both the left and right side
o Polar: Polar coordinate plot.
o Semilogx: Semilogarithmic plot.
o Semilogy: Semilogarithmic plot.
o Subplot: It creates an axis in tiled positions.
o Xlim: Sets or queries x-axis limits.
o Ylim:: Sets or queries y-axis limits.
o Zlim: Sets or queries z-axis limits.

13) What are the four essential functions to solve Ordinary


Differential Equations (ODE)?
The four primary functions that MATLAB has to solve ODE's are
Quad
Quad8
ODE23
ODE45

14) What is latex in MATLAB?


MATLAB already deals naturally with simple latex encoding that enables introducing
Greek letters or changing the font size and displays in plots.

15) What do you mean by M-file in MATLAB?


M-files are nothing but just a plain ASCII script that is interpreted at run time. We can
say these are the subprograms stored in text files with .m extensions and are known as
M-files. M-files are used for most of the MATLAB development, and platform
independence and maintainability. It is parsed once and "just-in-time" compiled, but it is
also transparent to the customer.

16) What are the MEX files?


MEX files are native C or C++ files that is dynamically connected directly into the
MATLAB application at runtime. It allows using C, C++, and Fortran programs in
MATLAB. They must be compiled for each hardware structure on which they are to be
run.
17) What are the standard toolboxes present in MATLAB and how
these toolboxes can be accessed?
Various types of toolboxes available are:
o Control Systems
o Fuzzy Logic
o Image Processing
o LMI Control
o Neural Networks
o Optimization
o Partial Differential Equation
o Robust Control
o Signal Processing
o Statistics
o Symbolic Math
o System Identification
o Wavelets

To create this Toolbox, go to the MATLAB Start menu, then go to the Toolboxes
submenu, then select the Toolbox which we want to use.

20) What Is Pseudo-Random Binary Sequence and Numeric


Precision In MATLAB?
Pseudorandom binary sequence: A form of creating an M-file in the new Frequency
Domain System Identification Toolbox, for a specified set of lengths (2^2-1 to 2^30-1) is
called a pseudo-random binary sequence. It is also called a mlbs (Maximum Length,
Binary Sequence).
Numeric precision: Numeric quantities that are represented as double-precision
floating-point numbers is called numeric precision. In systems, such numbers have 53
significant binary bits, which is about 15 or 16 decimal digits.

21) Can We Run MATLAB without Graphics?


Sometimes we may want to run scripts that involve plotting commands without showing
the plots and without going into the script to comment out the commands.
An example: if we are working from home and it's too slow to run graphics over the
network. We can play a simple UNIX trick:
%setenv DISPLAY /dev/null % matlab

22) What is a P-code?


Pcode is a prepared and encoded version of the M-file. It stores the load time of the
function. This is most likely not an issue except for very high M-files since most are
parsed only once anyway. Pcode also lets us hide the source code from others. There is
no way to change Pcode back to the M-file source. Pcode is platform-independent.

23) Explain about the mentioned tools in MATLAB: who, whos, pi,
eps, type.
Who: It will show you all the variables you have currently defined.
whos: It will show you the variables, their sizes, and some other info.

pi: It is a function that returns the equation of pi.

eps: It is a function that returns MATLAB?s lowest floating-point number. This is useful if
we have a vector that might include zeros that are going to wind up in the denominator
of something. If we add eps to the vector, you aren't adding anything significant, but we
won't run into a divide by zero problems anymore

Type: function name for any function in MATLAB?s search path lets us see how that
function is written.

25) How can the source code can be executed on MATLAB?


By default, the code is generally stored with in (.m) extension, which is anchored
however if the customer needs it to be put away in a more anchored way then he can
attempt the accompanying methods:
1. Influence it as P-to code: Convert a few of the most significant part of our
source code files to the text darkened shape known as P-code document (from
its. p document extension), and disseminate our program code in this
configuration.
2. Accumulate into the double solution: Compile your source code files using the
MATLAB Compiler to produce an independent function. Appropriate the last to
end-user of our application.

26) How to plot a graph in MATLAB?


Ans. For any two points, x and y, with some values given, a function called plot
(x, y) are used to plot a graph in MATLAB.
x : [value of array];
y : [value of array];
plot(x, y)

27) How to call a function in MATLAB?


Ans. A function in MATLAB can be called using the name you give to the function, but
first, it needs to be written in the New Script tab under the File Tab. You can simply call
the function by writing the function’s name in the code area.
28) What is MATLAB used for?
Ans. MATLAB language is a high-level matrix language. It has control structures,
functions, data structures, input/ output, and OOP features. MATLAB API allows to the
author of C and FORTRAN programs to interact with MATLAB. It is used for various
industry-level designing processes and for running the control systems and automation
of different types of machines by defining a particular set of codes for an object.

29) How to use for loop in MATLAB?


Ans. A for loop is used to repeat a certain set of instructions a fixed number of times.

The syntax of for loop is:

1 for index = values


2 statements
3 end
for index = values, statements, end executes a group of statements in a loop for a
specified number of times.

30) How to open SIMULINK in MATLAB?


Ans. SIMULINK can be easily accessed in MATLAB by the use of the Home tab. Simply
go to the Home tab and click Simulink.

31) How to write for loop in MATLAB?


Ans. Here is presented an example of ‘for loop’ in MATLAB:

A = [3 6 9 4 1];

for i = 1:length(A)

disp(A(i))

end

As discussed earlier, a for loop is used is often used to assign to or access array
elements iteratively.

32) How to create a matrix in MATLAB?


Ans. To create an array with n number of elements in m number of rows, separate the
elements with either a space or a comma. For example, to create a matrix A of order 3
X 3, we write it as:
A = [ 21 92 43, 45 67 54, 72 88 91 ]

The result to which will be represented as:

A=3X3

21 92 43

45 67 54

72 88 91

33) How to stop a program in MATLAB?


Ans. You can simply use the quit command to stop a program in MATLAB or the
desktop shortcut such as Ctrl + C.

You might also like