How to Describe MATLAB Functions in Academic Writing

If you have ever pasted a MATLAB function into an assignment and then wondered, “What am I actually supposed to say about this code?”, you. They emphasise attribution, unique identification, accessibility, persistence, and identifying the specific version used. current R2026b documentation describes capabilities and syntax that have evolved across previous releases. -defined MATLAB function was developed to calculate the simulated output of the proposed control system.

The function accepts the system parameters, input signal, and simulation time as inputs and returns the corresponding output response. The calculation is based on the state-space representation of the system, which is constructed from the specified system matrices before the response is simulated. Zero initial conditions were assumed, and the simulation was performed over the selected time interval. The resulting output was compared with the expected system’s response to a unit-step input, allowing its transient behaviour to function calculates settling time, explain why settling time matters.

If it simulates a controller, explain what aspect of controller performance you are investigating what it produces, and how that output fits into the wider analysis. Then give would also keep your code and your written explanation consistent. If the report says the function uses one set of parameters but the submitted MATLAB file uses another, no amount of polished writing will fix the are not alone.

The difficult part is usually not understanding what the function does. It is explaining it in a way that makes sense to someone reading your report without having to inspect every line of your .m file.

I find the easiest way to approach this is to stop thinking of the function as “code that needs explaining” and start treating it as part of your methodology. Your MATLAB code carries out the calculation; your academic writing explains why that calculation was needed, what it used, what it produced, and how you know the result is reasonable.

What should you say about a MATLAB function?

A MATLAB function normally has a name, inputs, outputs, and a body containing the calculations. For example:

function y = calculateOutput(x,k)

y = k .* x;

end

MATLAB’s current documentation describes a function declaration in terms of its name, input arguments, and output arguments. The declaration must be the first executable statement in the function. MathWorks

But you would not normally explain this function in an academic report by saying:

The function has one input, one output and performs multiplication.

That is true, but it tells your reader very little about the role of the calculation.

A better explanation would be:

The calculateOutput function was used to scale the input signal according to the selected gain. The input vector x represents the signal being analysed, while k represents the applied gain. The function returns the scaled signal, which is subsequently used in the system analysis.

Now the reader knows what the function is doing in the context of your work.

That is the key difference between documenting code and writing academically about code.

Start with the purpose, not the syntax

When I describe MATLAB code in a report, I usually begin with one simple question:

Why does this function exist in the analysis?

That question often gives you the first sentence of your paragraph.

For example:

A user-defined MATLAB function was developed to calculate the output response for a given set of system parameters.

You can then explain how it achieves that purpose.

This approach also prevents one of the most common problems with technical assignments: spending several paragraphs explaining programming syntax while barely discussing the engineering or mathematical problem.

Your reader is usually more interested in the latter.

Explain the inputs and outputs clearly

Once you have explained the purpose, tell the reader what goes into the function and what comes out.

For example:

function y = calculateResponse(t,u,K)

You could write:

The function accepts the simulation time vector t, the input signal u, and the system gain K. It returns y, representing the calculated system response over the specified simulation interval.

If the variables have physical units, include them.

For example:

The time vector t is expressed in seconds, while u represents the applied input signal. The gain K is dimensionless, and the returned vector y represents the corresponding system output.

This is much more useful than simply listing the variable names.

If the dimensions matter, mention them too. A matrix used to represent a state-space model, for instance, should not be described in exactly the same way as a scalar gain.

MATLAB also supports arguments blocks for defining and validating input and output requirements. These can specify characteristics such as dimensions, data types, validators, and default values. MathWorks+1

That can be worth mentioning when argument validation is an important part of your implementation.

Explain what the calculation means

After introducing the inputs and outputs, explain the actual operation.

You do not need to describe every line.

Suppose your function contains:

function y = calculateOutput(x,k)

y = k .* x;

end

A useful explanation would be:

The function performs element-wise multiplication between the input vector and the specified gain. Consequently, each sample of the input signal is multiplied by the same gain before the resulting vector is returned.

That is enough for a simple function.

For a more complicated function, break the calculation into logical stages rather than commenting on individual lines.

For example:

  1. The input parameters are received.
  2. The mathematical model is constructed.
  3. The required simulation is performed.
  4. The resulting data are returned for further analysis.

This makes the explanation easier to follow and avoids turning your report into a copy of the source code.

Use MATLAB examples that relate to your subject

The best explanation depends on what you are actually using MATLAB for.

In control engineering, for example, functions such as tf, ss, step, lsim, and stepinfo can form part of a normal analysis workflow. MATLAB’s Control System Toolbox provides functions for analysing time-domain and frequency-domain responses, including step responses, Bode plots, settling time, rise time, overshoot, and stability margins. MathWorks

Consider a simulation using lsim:

sys = ss(A,B,C,D);

y = lsim(sys,u,t);

Rather than writing:

The ss function was used, followed by the lsim function.

I would write:

The state-space matrices were first used to construct the system model. The lsim function was then used to simulate the model’s response to the specified input signal over the selected time interval.

That description tells the reader what happened and why.

MATLAB’s documentation confirms that lsim computes the time response of a dynamic system to an arbitrary input and accepts the system model, input signal, and time samples as key arguments. MathWorks

Connect MATLAB functions to the mathematics

This is where an ordinary programming description can become a strong academic explanation.

Suppose you are working with a state-space model:

x˙=Ax+Budot{x}=Ax+Bu

y=Cx+Duy=Cx+Du

If you use MATLAB’s ss function to represent that model, explain the relationship between the code and the equations.

For example:

The state-space representation was implemented in MATLAB using the system matrices AA, BB, CC, and DD. This representation was then used to simulate the system response under the specified input conditions.

The code and mathematics now support each other.

That is much more convincing than simply displaying:

sys = ss(A,B,C,D);

without explanation.

Explain built-in and user-defined functions differently

Another small distinction can make your report sound much more precise.

If you use a MATLAB function that already exists, identify it as a built-in or toolbox function where appropriate:

MATLAB’s step function was used to obtain the system’s response to a step input.

If you wrote the function yourself, make that clear:

A user-defined function was developed to calculate the performance metric from the simulated response.

This tells the reader which parts of the analysis rely on MATLAB’s existing functionality and which parts represent your own implementation.

MATLAB’s own documentation is particularly useful here because its function references provide syntax, input and output descriptions, and examples. The help and doc commands can also be used to access this information directly from MATLAB. MathWorks+1

If you are struggling to connect MATLAB code to the methodology section of a control assignment, targeted control system matlab assignment writing help can also be useful as a supplementary resource. You should still make sure that your final report accurately reflects the work and results you actually produced.

Do not explain every line of code

This is probably the biggest change I would make to a student’s first draft.

Imagine a function contains 30 lines of MATLAB code. You do not need 30 corresponding sentences in your report.

Instead, group related operations together.

For example, instead of:

Line 1 defines the variable. Line 2 calculates the gain. Line 3 creates the transfer function. Line 4 calculates the response.

You could write:

The function first establishes the required system parameters and constructs the corresponding transfer-function model. The model is then simulated under the specified input conditions, and the resulting response is returned for performance analysis.

The second version reads like academic writing rather than annotated source code.

Explain assumptions and units

A MATLAB function can be perfectly valid code and still produce a misleading result if the assumptions behind it are unclear.

For that reason, mention anything that could affect how the reader interprets the result.

Depending on your project, this might include:

  • Units used for physical quantities
  • Initial conditions
  • Sampling interval
  • Simulation duration
  • Parameter values
  • Numerical assumptions
  • Model simplifications
  • Input constraints
  • Controller settings

For example:

The simulation assumes zero initial conditions and uses a sampling interval of 0.01 s. All model parameters are expressed in SI units.

That one sentence can provide important context for someone trying to reproduce your work.

Show how you checked the function

Do not simply write:

The MATLAB function was tested and found to be correct.

That sounds reassuring, but it does not tell the reader how you tested it.

Instead, describe the check you actually performed.

For example:

The function was tested using a nominal input for which the expected output could be calculated independently. The MATLAB result was then compared with the independently calculated value to check the implementation.

For a control-system simulation, you might compare the numerical result with expected system behaviour or with a known analytical result.

If you use stepinfo, for instance, MATLAB can calculate characteristics such as rise time, settling time and other step-response measures from a system model or response data. MathWorks

You can therefore write something like:

The simulated step response was evaluated using stepinfo to obtain the rise time and settling time. These values were then compared with the performance requirements specified for the controller.

That is a methodological statement rather than a generic claim that “MATLAB was used for analysis.”

Include a small example when it helps

A short example can make your explanation much easier to understand.

Consider:

function y = squareSignal(x)

y = x.^2;

end

You could explain it as:

The squareSignal function calculates the square of each element in the input vector. For an input of [1 2 3], the resulting output is [1 4 9]. The function was used where squared signal values were required during the subsequent numerical analysis.

You do not need to add examples like this for every function in a large project. Use them when the reader might otherwise have to guess what the code is doing.

Cite MATLAB when it forms part of your research method

If MATLAB materially contributes to your research, do not treat it as invisible background software.

Software is a research product, and the FORCE11 Software Citation Principles recommend that research software be cited in scholarly work. They emphasise attribution, unique identification, accessibility, persistence, and identifying the specific version used. Force11+1

That means a methodology section might say:

The simulations were performed in MATLAB using the relevant control-system functionality. The MATLAB release and toolbox versions were recorded to support reproducibility.

The exact citation format should follow your university, department, journal, or referencing style.

The version can matter more than students sometimes realise. MATLAB’s functionality changes between releases. For example, the current R2026b documentation describes capabilities and syntax that have evolved across previous releases. MathWorks+1

If someone needs to reproduce your work, knowing which environment you used can therefore be useful.

A simple structure you can reuse

When you are stuck describing a MATLAB function, use this order:

  1. Purpose — Why was the function used?
  2. Inputs — What information does it receive?
  3. Outputs — What does it return?
  4. Calculation — What does it actually do?
  5. Context — How does it relate to your mathematical or engineering model?
  6. Assumptions — What conditions or units should the reader know about?
  7. Verification — How did you check that it worked?
  8. Reproducibility — What MATLAB version, toolbox, parameters, or settings matter?

You can turn those points into a compact paragraph.

For example:

A user-defined MATLAB function was developed to calculate the simulated output of the proposed control system. The function accepts the system parameters, input signal, and simulation time as inputs and returns the corresponding output response. The calculation is based on the state-space representation of the system, which is constructed from the specified system matrices before the response is simulated. Zero initial conditions were assumed, and the simulation was performed over the selected time interval. The resulting output was compared with the expected system behaviour to verify the implementation.

That is generally enough for a report unless your supervisor specifically asks for a detailed algorithm or code walkthrough.

Common mistakes to avoid

Describing the code instead of the research

The step function creates a graph.

Technically correct, but incomplete.

Try:

The step function was used to determine the system’s response to a unit-step input, allowing its transient behaviour to be evaluated.

Giving unexplained variable names

Avoid writing:

The function uses x, u, A, B, and C.

Tell the reader what those variables represent.

Making unsupported claims

Avoid:

The function provides accurate results.

Explain what you compared it against or how you validated it.

Repeating the code in prose

Your report should not become a sentence-by-sentence translation of the .m file.

Focus on the decisions, calculations, assumptions, and results that matter to the study.

Forgetting the connection to your research question

This is perhaps the most important point.

A reader should be able to understand why the function was necessary.

If your function calculates settling time, explain why settling time matters. If it simulates a controller, explain what aspect of controller performance you are investigating. If it processes experimental data, explain what information the processing extracts.

Final thought

Good academic MATLAB writing is not about making your code sound complicated. In fact, the opposite is usually true.

Explain the function plainly. Tell the reader what it was used for, what information it needs, what it produces, and how that output fits into the wider analysis. Then give enough technical detail for someone with a similar background to understand and reproduce the procedure.

I would also keep your code and your written explanation consistent. If the report says the function uses one set of parameters but the submitted MATLAB file uses another, no amount of polished writing will fix the credibility problem.

The strongest MATLAB reports make the relationship between code, mathematics, methodology, and results obvious. Once you write with that connection in mind, describing functions becomes much easier and your report sounds like an engineering or scientific analysis rather than a collection of code comments.

Comments

  • No comments yet.
  • Add a comment

    Ha valaki egy üzleti katalógusban vagy cégkereső oldalon böngészik, gyakran találkozik a pénzügyi és digitális szolgáltatások egyre színesebb kínálatával is. A hagyományos fizetési megoldások mellett mára önálló kategóriává nőttek a kriptovalutákat elfogadó platformok, köztük a bitcoin fogadás lehetőségét kínáló oldalak, ahol a felhasználók akár Bitcoinnal is feltölthetik egyenlegüket. Az ilyen szolgáltatások kiválasztásakor érdemes körültekintően eljárni, és felelős szerencsejáték-szemlélettel, kizárólag olyan összeget kockáztatni, amelynek elvesztése nem okoz anyagi gondot.