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;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.