Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Below is user-defined MATLAB function and a separate script that cells the funct

ID: 3581938 • Letter: B

Question

Below is user-defined MATLAB function and a separate script that cells the function: function [ret] = plot_stuff(x, y, plotfune) ret=figure; if nargin == 2 ret = plot (x, y); else plotfunc (x, y) else plotfunc (x, y); end end %SCRIPT to test plot_stuff function close all; t = (0:0.5; 10); y = exp (t); h = plot_stuff(t, y); h=plot_stuff(t, y); h = plot_stuff(t, y @ semilogy); figure Create figure window. H = figure, by itself, creates a new figure window, and returns its handle. Inside the body of a user-defined function, nargin returns the number of input arguments that were used to call the function. plot Linear plot. h = plot (x, Y plots vector Y versus vector x. Plot returns a column vector of handles h plot to lineseries objects, one handle per plotted line. semilogy Semi-log scale plot. h=semilogy (...)is the same as PLOT(...), except a logarithmic (base 10) scale is used for the Y-axis exp Exponential. exp (x) is the exponential of the elements of x, e to the x. If the script above is run in MATLAB, answer the following questions: How many figure windows are opened? What type of output argument(s) does plot-stuff return after the first call to the function. What type of output argument(s) does plot_stuff return after the second call to the function. Which plot below corresponds to the second call to the plot_stuff function?

Explanation / Answer

a. How many figure windows are opened?

2 windows. One for each call of plot_stuff().

b. What type of output arguments does plot_stuff return after the first call to the function. It returns a figure handle.

c. What type of output arguments does plot_stuff return after the second call to the function. It also returns a figure handle.

d. Which plot below corresponds to the second call to the plot_stuff function? Fig 1, i.e., the straight line corresponds to the second call.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote