Recall & Review
beginner
What are input arguments in a MATLAB function?
Input arguments are values or variables passed into a function when it is called. They provide the function with data to work on.
Click to reveal answer
beginner
What are output arguments in a MATLAB function?
Output arguments are values that a function returns after execution. They allow the function to send results back to the caller.
Click to reveal answer
beginner
How do you define a function with one input and one output argument in MATLAB?
Use the syntax: <br>
function output = functionName(input) <br> where input is the input argument and output is the output argument.Click to reveal answer
intermediate
Can a MATLAB function have multiple output arguments? How?
Yes. Use square brackets to list multiple outputs: <br>
function [out1, out2] = functionName(in1, in2) <br> This returns two outputs from the function.Click to reveal answer
intermediate
What happens if you call a MATLAB function without specifying output arguments?
If no output is specified, MATLAB will not store the returned values. The function still runs, but outputs are discarded unless the function displays them.
Click to reveal answer
How do you declare a MATLAB function that takes two inputs and returns one output?
✗ Incorrect
The correct syntax is: function output = func(input1, input2). Inputs go in parentheses, output before the equals sign.
What symbol is used to enclose multiple output arguments in a MATLAB function definition?
✗ Incorrect
Square brackets [ ] are used to list multiple output arguments in MATLAB function definitions.
If a MATLAB function has outputs but you call it without assigning outputs, what happens?
✗ Incorrect
If outputs are not assigned, MATLAB runs the function but discards outputs unless the function prints them.
Which of these is a valid way to call a function with two outputs in MATLAB?
✗ Incorrect
The correct way is to use square brackets on the left: [a, b] = myFunc(x, y).
What keyword starts a function definition in MATLAB?
✗ Incorrect
MATLAB functions start with the keyword 'function'.
Explain how input and output arguments work in MATLAB functions.
Think about how you give information to a function and how it sends back results.
You got /4 concepts.
Describe what happens if you call a MATLAB function with outputs but do not capture those outputs.
Consider what happens if you ignore the results a function gives you.
You got /4 concepts.