MATLAB User Defined Functions please me through my HW because i\'m not sure with
ID: 3757838 • Letter: M
Question
MATLAB User Defined Functions
please me through my HW because i'm not sure with my answers:
These are the questions:
1. Anonymous functions can show up in the workspace window as function handles. (True or False)
2.What type of function is on the first line and what is its name?
function height=rocket(t)
%accepts inputs of time in seconds and outputs height in meters
height = @(t) -(9.8/2)*(t.^2) + 125*t + 500;
height(t)
end
which statement(s) is/are right:
A. user-defined function, rocket
B. function handle, height
C. subfunction, height
D. anonymous function, height
E. user-defined function, height
F. nested function, rocket
3. For the following function:
[ x, a]=newfun2(r1,r2,r3,r4,r5,r6)
which statement(s) is/are right:
A. x is an output
B. a is an input
C. newfun2 is a well-known MATLAB built-in function
D. r2 is an input
E. r3 is an o utput
4. Given a user-defined function called distance(t)
which of these is correctly coded:
A. fplot('distance', [0,40])
B. fplot(distance, [0,40])
C. fplot(@distance, [0,40])
D. fplot('distance(t)', [0,40])
5.Subfunctions do not share the main function's function space and thus require inputs to be passed from the main function to the subfunction. (True/False)
Thank you before :)
Explanation / Answer
1. Function handles can refer to built-in MATLAB functions, to your own function in an M-file, or to anonymous functions.
Anonymous functions can implicitly refer to variables in the workspace.
Therefore, Anonymous functions cannot show up in the workspace window as function handles.
Hence, correct answer is FALSE
2. What type of function is on the first line and what is its name?
function height=rocket(t) %This is user-defined function and name of the function is racket().
%accepts inputs of time in seconds and outputs height in meters
height = @(t) -(9.8/2)*(t.^2) + 125*t + 500; % This is anonymous function.
height(t)
end
Which statement(s) is/are right?
A. user-defined function, rocket
B. function handle, height
C. sub function, height
D. anonymous function, height
E. user-defined function, height
F. nested function, rocket
3. For the following function:
[ x, a]=newfun2 (r1, r2, r3, r4, r5, r6)
Which statement(s) is/are right?
A. x is an output
B. a is an input
C. newfun2 is a well-known MATLAB built-in function
D. r2 is an input
E. r3 is an output
4. Given a user-defined function called distance(t)
Which of these is correctly coded?
A. fplot('distance', [0,40])
B. fplot(distance, [0,40])
C. fplot(@distance, [0,40])
D. fplot('distance(t)', [0,40])
5.True.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.