0
0
MATLABdata~5 mins

Input and output arguments in MATLAB - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Afunction (input1, input2) = output func
Bfunction output = func(input1, input2)
Cfunction func = output(input1, input2)
Dfunction [input1, input2] = func(output)
What symbol is used to enclose multiple output arguments in a MATLAB function definition?
ASquare brackets [ ]
BCurly braces { }
CParentheses ( )
DAngle brackets < >
If a MATLAB function has outputs but you call it without assigning outputs, what happens?
AMATLAB throws an error
BOutputs are returned and stored automatically
COutputs are discarded unless displayed inside the function
DFunction does not run
Which of these is a valid way to call a function with two outputs in MATLAB?
Aa, b = myFunc(x, y)
BmyFunc(x, y) -> a, b
CmyFunc[a, b](x, y)
D[a, b] = myFunc(x, y)
What keyword starts a function definition in MATLAB?
Afunction
Bdef
Cfunc
Dbegin
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.