Complete the code to define a local function named 'square' that returns the square of input 'x'.
function y = main()
y = square(5);
end
function result = [1](num)
result = num^2;
endThe local function must be named 'square' to match the call in the main function.
Complete the code to call the local function 'greet' inside the main function.
function main()
message = [1]('Alice');
disp(message);
end
function msg = greet(name)
msg = ['Hello, ' name '!'];
endThe local function is named 'greet', so the call must use 'greet'.
Fix the error in the local function definition by completing the function header correctly.
function output = main()
output = addFive(10);
end
function result = [1](x)
result = x + 5;
endThe function name must exactly match the call in main, which is 'addFive'.
Fill both blanks to create a local function 'multiply' that multiplies two inputs 'a' and 'b'.
function result = main()
product = multiply(3, 4);
disp(product);
end
function [1] = [2](a, b)
[1] = a * b;
endThe function output variable is 'result' and the function name is 'multiply' to match the call.
Fill all three blanks to create a local function 'concatStrings' that joins two strings with a space.
function result = main()
combined = concatStrings('Hello', 'World');
disp(combined);
end
function [1] = [2](str1, str2)
[1] = [str1 [3] str2];
endThe output variable is 'result', the function name is 'concatStrings', and the space character is ' ' to join the strings.