Question: Write a code using while loop in Matlab: (1) Create an empty vector v (i.e., v = [ ];) (2) Generate a random integer between

Write a code using while loop in Matlab:

(1) Create an empty vector v (i.e., v = [ ];)

(2) Generate a random integer between -50 and 50 (inclusive).

(3) If the number is 40 or less then put the number at the end of v (the length of v will increase by 1), generate another random number, and repeat this analysis.

(4) If the number is more than 40 then put the number at the end of v (the length of v will increase by 1) and stop generating numbers.

And after this:

Write a script which performs the same analysis as in above question five times by using a for loop. Each time you finish creating a vector of random numbers, plot it as a data series using a solid line with open circles. All five vectors should be plotted on the same plot. Label your axes clearly, add a legend, and title.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!