Return Multiple Values From a Matlab Function

This tutorial will discuss how to return multiple values from a function using the box brackets in MATLAB.

Return Multiple Values From a Function Using the Box Brackets in MATLAB

If you want to return multiple values from a function, you have to define all of them inside a box bracket separated by a comma and assign them the required output within the function bounds. For example, let’s create a function and return three values. See the code below.

[a,b,c] = fName()
function [a,b,c] = fName()
    a = 1;
    b = 2;
    c = 5;


a =


b =


c =


As you can see in the output, three values have been returned by the function.

DelftStack is a collective effort contributed by software geeks like you. If you like the article and would like to contribute to DelftStack by writing paid articles, you can check the write for us page.

Related Article - MATLAB Function

  • MATLAB Recursive Function
  • MATLAB Optional Arguments