Call Functions

These examples show how to call a MATLAB® function. To run the examples, you must first create numeric arrays A and B, such as:

A = [1 3 5];
B = [10 6 4];

Enclose inputs to functions in parentheses:

max(A)

Separate multiple inputs with commas:

max(A,B)

Store output from a function by assigning it to a variable:

maxA = max(A)

Enclose multiple outputs in square brackets:

[maxA, location] = max(A)

Call a function that does not require any inputs, and does not return any outputs, by typing only the function name:

clc

Enclose text string inputs in single quotation marks:

disp('hello world')

Related Examples

Was this topic helpful?