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

Section 2: Building step and ramp functions in Matlab The following function app

ID: 647462 • Letter: S

Question

Section 2: Building step and ramp functions in Matlab The following function applies the unit step function to each element of an input vector x. Copy and save this file as u.m in the default workspace and then create the graph of the unit step function using the directions provided.

function y = u(x)

for n = 1: length(x)

if (x(n) < 0) y(n) = 0;

else y(n) = 1;

end

end

end

Testing the function:

Section 2: Building step and ramp functions in Matlab The following function applies the unit step function to each element of an input vector x. Copy and save this file as u.m in the default workspace and then create the graph of the unit step function using the directions provided. function y = u(x) for n = 1: length(x) if (x(n)

Explanation / Answer

for i=1:20
      x(i) = i-10;
      y(i) = x(i) ^ 2;
    end

    % Plot the X values vs. the Y values
    plot(x,y);

    % Label the plot
    xlabel('X axis');
    ylabel('Y axis');
    title('Graph of X^2');
    legend ('X squared');
    grid on;

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