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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started