Write a MATLAB script entitled CosWavem that plots ycosx usi

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.

Solution

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

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)

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site