Q:

Write a script that will prompt the user for a character. It will create an x-vector that has 50 numbers, equally spaced between -2π and 2π, and then a y-vector which is cos(x)

0

Write a script that will prompt the user for a character. It will create an x-vector that has 50 numbers, equally spaced between -2π and 2π, and then a y-vector which is cos(x). If the user entered the character ‘r’, it will plot these vectors with red *s – otherwise, for any other character it will plot the points with green +s. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch4Ex10.m

color = input('Enter a char for a color: ', 's');

x = linspace(-2*pi, 2*pi, 50);

y = cos(x);

if color == 'r'

 plot(x,y,'r*')

else

 plot(x,y,'g+')

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now