Write code to ask the user to enter a color as a string


Please answer all of these MATLAB questions.

1) Variables are used to store data in the computer. All variables have a type that specifies what kind of data the variable contains. Create 5 new variables ( one for each basic data type) and give them a value.

2) Given a variable answer, write one line of code that produces true if the answer is either 'y' or 'n' and false otherwise.

3) Create a random floating point number between 10 and 50. Store this number in a variable named my_float. Create a random integer between -10 and -50. Store this number in my_int.

4) Write a while loop that will display the odd numbers from 7 to 21.

5) Write code to ask the user to enter a color (as a string; valid colors are 'red', 'yellow', 'blue'). Keep asking until a valid color is entered.

6) Write the function is_array_odd() that takes in an array and returns true if values in the array are odd, and false otherwise.

7) Write the draw_line() function. It should take in a line, and plot the line on the screen. The draw_line() function should optionally allow the user to pass in a color. If so, draw the line in that color, if not, draw the line in red.

Request for Solution File

Ask an Expert for Answer!!
MATLAB Programming: Write code to ask the user to enter a color as a string
Reference No:- TGS02887443

Expected delivery within 24 Hours