Write a MATLAB script entitled “CosWave.m” that plots y=cos(x) using a linearly
ID: 3009948 • Letter: W
Question
Write a MATLAB script entitled “CosWave.m” that plots y=cos(x) using a linearly spaced x-vector generated with the “linspace” function (do not use a “for” loop). Plot with a range from x=0 to x=4*pi with 100 points, using black circles and a black dashed line. Label the plot title “Cosine Wave,” label the x-axis “Independent Variable,” and label the y-axis “Dependent Variable.” Initialize variables and add comments on each line that explains their purpose. Turn in (i) the script, as well as (ii) an image of the plot.
Explanation / Answer
Here goes the script inside the function CosWave.m
x = linespace(0, 4*pi)
y = sin(x)
figure
plot(x,y,'--ko') % -- is for dashed line k is for black color o is for circle
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.