a) Using the linspace function create an array called X of length 500 ranging in
ID: 3542386 • Letter: A
Question
a) Using the linspace function create an array called X of length 500 ranging in value from 0 to
4?.
b) Create an array called Y who's values correspond to the sine of the values in X.
c) Create an array called Z who's values correspond to the sine of the square of the values in X.
d) Plot Y vs. X, and Z vs. X on the same axis using the plot command. Make the Y vs. X line a
dashed red line and Z vs. X a solid blue line with circular markers at each data point. Create
a legend which identifies which line is which. Create a title for this figure with the text
Explanation / Answer
%%%%%(a)
X = linspace(0,4*pi,500);
%%%%(b)
Y = sin(X);
%%%%(c)
Z = sin(X.^2);
%%%%(d)
plot(X,Y,'r--')
hold
plot(X,Z,'b')
hold
legend('Y vs X','Z vs X');
title('Part 2d')
grid on
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.