MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

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 inputs in single quotation marks:

disp('hello world')

See Also


Related Examples



  • “Ignore Function Outputs” on page 1-4


Call Functions
Free download pdf