Question: Function Name: functionHeader Inputs: 1. (char) A function name 2. (double) The number of inputs 3. (double) The number of outputs Outputs: None File Outputs:
Function Name: functionHeader
Inputs:
1. (char) A function name
2. (double) The number of inputs
3. (double) The number of outputs
Outputs:
None
File Outputs:
1. A .txt file containing the function header
Background: You have been selected to be CS 1371 TA for a day! You take a break from video games to fulfill your duties as an honorary TA. You are writing a new auto-grader and have been tasked with making sure that students who use banned functions in their homework get a zero. Your idea is to overwrite each banned function with a "dummy" function that does not give the proper output. For example, if the mean() function is banned, your code should write a new mean() function that overwrites the built in one, so that if a student's code calls the mean() function, it will result in an incorrect answer.
Function Description: Write a function that takes in a function name, a number of inputs, and a number of outputs, and writes a text (.txt) file containing the function header. In the function header, the base word for the variables should be in and out, respectively. After the function header, include a blank line, followed by the end keyword. As is the case with any MATLAB function, the file name should be identical to the function name.
Example:
>> functionHeader('myFunc', 3, 2)
myFunc.txt
1 function [out1 out2] = myFunc(in1, in2, in3)
2
3 end
Notes:
If there are no outputs, you should include empty brackets and the assignment operator.
Do not put commas between outputs.
Be careful with spaces; your file should match the solution file exactly. If you are unsure, run the solution file and use visdiff() to compare your output file to the solutions.
There should not be an additional newline at the end of the file.
--------
MATLAB PLEASE
banned: fileread() and textscan()
% Test Cases:
% functionHeader('myFunc', 2, 1)
% Output text file(s) should be identical to that produced by the solution file
% Output variable(s) should be identical to those produced by the solution file
%
% functionHeader('anotherOne', 2, 3)
% Output text file(s) should be identical to that produced by the solution file
% Output variable(s) should be identical to those produced by the solution file
%
% functionHeader('funcY', 1, 0)
% Output text file(s) should be identical to that produced by the solution file
% Output variable(s) should be identical to those produced by the solution file
%
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
