MATLAB interview questions, from indexing to Simulink

MATLAB interview questions check whether you can write correct, fast numerical code and use it for real engineering work: matrix indexing, element-wise versus matrix operators, preallocation and vectorization, cell arrays, structs and tables, function handles, solving linear systems and ODEs, and plotting results clearly. Engineering roles often add Simulink, toolboxes such as Signal Processing or Control System, and code generation. Interviewers want to see that you understand the math your code is doing.

By Published 7 min read

How MATLAB shows up in interviews

MATLAB is used in controls, signal and image processing, automotive and aerospace, robotics, power systems, finance, and academic research. In most interviews it is a tool inside an engineering conversation rather than the main topic: you will be asked to filter a signal, simulate a system or analyze test data, and the code is how you show it. Roles in model-based design lean heavily on Simulink. If you are also interviewing in Python, expect to compare the two; the pandas and NumPy questions cover the Python side of numerical work.

  1. Technical screenShort questions on indexing, operators, data types and common functions, sometimes predicting what a line returns.
  2. Coding taskWrite a function to process data, such as smoothing a signal, finding peaks or fitting a curve, live or as a take-home.
  3. Domain discussionExplain the math and engineering behind your code: a filter design, a controller, a numerical method, an estimation.
  4. Simulink or tooling roundFor model-based design roles: build or debug a small model, discuss solvers, sample times, testing and code generation.

Fundamentals: matrices, indexing and operators

Core MATLAB questions, what they test, and what a strong answer shows
QuestionWhat it testsWhat a strong answer shows
How does MATLAB index arrays?IndexingFrom 1, by row and column, with linear indexing that runs down columns first (column-major order), and end for the last element
What is the difference between * and .*?Operators* is matrix multiplication and needs matching inner dimensions; .* multiplies element by element. The same applies to / and ./ and ^ and .^
What is logical indexing?VectorizationUsing a logical array of the same size to select or change elements, such as A(A < 0) = 0
What does the colon operator do?RangesBuilds ranges like 1:2:9 and, as A(:), turns any array into a column vector
What is implicit expansion?BroadcastingElement-wise operations between compatible sizes expand automatically, such as subtracting a row of column means from a matrix
How do you find the size and number of elements of an array?Basicssize, numel, length (the largest dimension, which can surprise you) and isempty
Why can 0.1 + 0.2 == 0.3 be false?Floating pointBinary floating point cannot store those values exactly; compare with a tolerance such as abs(a - b) < tol
Core MATLAB questions, what they test, and what a strong answer shows. Scroll sideways on a small screen.
A = magic(4);   % [16 2 3 13; 5 11 10 8; 9 7 6 12; 4 14 15 1]

A(2, 3)         % 10           row 2, column 3
A(7)            % 7            linear index runs down columns
A(:, end)'      % 13 8 12 1    last column, transposed to a row
A(A > 10)'      % 16 11 14 15 13 12   logical indexing, column-major order

x = [1 2 3];
x .* x          % 1 4 9        element-wise
x * x'          % 14           inner product
size(x' * x)    % 3 3          outer product
Indexing on magic(4) (results checked with NumPy; MATLAB not run)

Data types, functions and code structure

  • When do you use a cell array, a struct or a table? Cells hold mixed types or uneven lengths, structs group named fields for one thing, and tables hold column-oriented data with names and types, like a spreadsheet.
  • What is the difference between a script and a function? Scripts share the base workspace and can clobber variables; functions have their own workspace, inputs and outputs, which makes them testable.
  • What are anonymous functions and function handles? A handle refers to a function so it can be passed around, as in f = @(x) x.^2 - 2; passed to fzero or integral.
  • How do you handle optional inputs? An arguments block with defaults and validation in newer versions, or nargin and inputParser in older code.
  • What is the difference between char arrays and strings? Single-quoted char arrays are character matrices; double-quoted strings are a newer string type with better functions for text work.
  • How does object-oriented MATLAB work? classdef files with properties and methods; value classes copy on assignment, handle classes share one object, which matters for things like device connections.
  • How do you read and write data files? readtable, readmatrix and writetable for tabular data, with import options for messy files, and save or load for MAT files.

Performance and numerical methods

Intermediate questions on speed and numerics
QuestionWhat it testsWhat a strong answer shows
Why preallocate arrays?PerformanceGrowing an array inside a loop reallocates memory each time; zeros or ones up front avoids that
Is vectorized code always better than a loop?JudgmentOften faster and shorter, but modern MATLAB compiles loops well; choose the clearer version and measure with the profiler
Why write A\b instead of inv(A)*b?Linear algebraBackslash picks a suitable factorization and is faster and more accurate; forming the inverse is rarely needed
What does the condition number tell you?Numerical stabilityHow much errors in the input can grow in the solution; a huge value warns that results may be unreliable
How do you choose between ode45 and ode15s?ODE solversode45 is a good default for non-stiff problems; ode15s suits stiff systems where ode45 takes tiny steps and crawls
How do you fit a curve to noisy data?Fittingpolyfit for polynomials, lsqcurvefit or the Curve Fitting tools for nonlinear models, and checking residuals rather than only R-squared
How would you speed up a long simulation sweep?ScalingProfile first, vectorize the inner work, use parfor if the Parallel Computing Toolbox is available, or move a hotspot to MEX
Intermediate questions on speed and numerics. Scroll sideways on a small screen.
% Preallocate instead of growing an array
n = 1e5;
s = zeros(1, n);
for k = 1:n
    s(k) = k^2;
end
s2 = (1:n).^2;          % vectorized equivalent
isequal(s, s2)          % true

% Solve A*x = b
A = [4 1; 2 3];
b = [1; 2];
x = A \ b               % [0.1; 0.6]

% dy/dt = -2y, y(0) = 1, exact answer exp(-2t)
f = @(t, y) -2 * y;
[t, y] = ode45(f, [0 2], 1);
y(end)                  % close to exp(-4), about 0.0183
Preallocation, a linear solve and an ODE (math checked by hand and in Python; MATLAB not run)

Signal processing, controls and toolboxes

  • How would you remove high-frequency noise from a sensor signal? Check the sample rate and the frequencies of interest, design a low-pass filter (for example a Butterworth with butter), and use filtfilt when zero phase shift matters and the data is offline.
  • What does the FFT tell you, and what are the common mistakes? The frequency content of a sampled signal; mistakes include forgetting the sample rate when building the frequency axis, ignoring windowing and leakage, and aliasing from too low a sample rate.
  • How do you model and analyze a system's response? A transfer function or state-space model with tf or ss, then step, bode and margin to look at speed, overshoot and stability margins.
  • How would you tune a PID controller? Start from a model if there is one, use a tuning tool or a method such as Ziegler-Nichols as a first guess, then check overshoot, settling time and robustness to model error.
  • Which toolboxes have you used, and for what? Name them with a task: Signal Processing for filtering, Control System for loop design, Optimization for parameter fitting, Statistics and Machine Learning for models. Be honest about depth.
Simulink and senior scenario questions
QuestionWhat it testsWhat a strong answer shows
What is the difference between fixed-step and variable-step solvers?SolversVariable-step adapts to the dynamics for accuracy in desktop simulation; fixed-step is needed for code generation and real-time targets
What is an algebraic loop, and how do you break it?Model debuggingA signal that depends on itself in the same time step; break it with a delay or memory block, or restructure the equations
How do you handle several sample rates in one model?MultirateSet sample times explicitly, use rate transition blocks between rates, and check the sample time colors
What is model-based design?ProcessRequirements linked to models, simulation to test early, automatic code generation, and checks such as model-in-the-loop, software-in-the-loop and hardware-in-the-loop
How do you test MATLAB and Simulink work?Qualitymatlab.unittest for functions, test harnesses for models, coverage reports and tests run in continuous integration
A simulation gives different results on a colleague's machine. What do you check?ReproducibilityMATLAB and toolbox versions, solver settings, random seeds, path differences and data files, ideally managed with a project and version control
How do you hand MATLAB code over to a software team?CollaborationClean functions with tests and documentation, generated code where the toolchain supports it, or a clear specification and reference data if they will reimplement it
Simulink and senior scenario questions. Scroll sideways on a small screen.

Fictional example

Answering "Tell me about MATLAB code you made faster"
On a battery test team, our script that processed overnight cycling data took about forty minutes per run. I profiled it and found two problems: a results array growing inside a loop over millions of samples, and a table lookup done row by row. I preallocated the array, replaced the lookup with logical indexing on the whole column, and moved a repeated readtable call out of the loop. The run dropped to under three minutes, and I added a unit test comparing the new output with a saved result from the old code so nobody had to trust my word. The team started running it after every test instead of once a day.

A two-week MATLAB practice plan

  • Days 1 to 3: indexing, operators and logical masks. Predict the output of twenty lines on magic(5), then check.
  • Days 4 to 6: functions, function handles, structs, cells and tables, with readtable on a real CSV.
  • Days 7 to 9: preallocation, vectorization and the profiler, then A\b, polyfit and one ODE problem solved two ways.
  • Days 10 to 12: the toolboxes the job lists: filter a noisy signal, analyze a step response, or fit a model.
  • Days 13 and 14: for Simulink roles, build a small closed-loop model, try both solver types and explain the differences out loud.

MATLAB roles often overlap with other languages and engineering jobs. R programming questions cover statistical analysis, Perl questions cover the scripting glue some labs still run, and the embedded software engineer guide shows where generated code ends up.

Being able to explain why your filter or solver choice is right matters as much as the code. Rehearse with Natively, an AI interview assistant for Mac and Windows: it transcribes the mock session so you can review your explanations, reads a problem statement or plot from a screenshot during practice, and can suggest a hint or approach. On Pro or the free trial it also uses the résumé and job description you add. Practice transcripts and notes are kept.

Questions people ask

What are common MATLAB interview questions?

How indexing works (1-based, column-major, logical), the difference between * and .*, why you preallocate, when to use cells, structs or tables, why A\b beats inv(A)*b, how to choose an ODE solver, and how you would filter a noisy signal.

Do MATLAB interviews include Simulink?

For controls, automotive, aerospace and other model-based design roles, often yes: solvers, sample times, algebraic loops, testing models and generating code. Pure analysis roles may skip it.

How do I prepare for a MATLAB coding test?

Practice indexing and vectorization until they are automatic, write small functions with clear inputs and outputs, use the profiler on a slow script, and solve a few problems from the job's domain such as filtering or curve fitting.

Is MATLAB or Python better for engineering interviews?

Use what the job lists. Many engineering teams use both, so it helps to know how a MATLAB task maps to NumPy, SciPy or pandas and to explain why a team might choose either.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP