Question: 1. Vector of Random Numbers (practice your FOR loops!) If you use the MATLAB function rand(1), it generates a random number between 0 and 1.

1. Vector of Random Numbers (practice your FOR loops!) If you use the MATLAB function rand(1), it generates a random number between 0 and 1. That is, if you use the command xrand(1) then x is a random number between 0 and 1, and every time it is called, x would be a different random number (a) Use a "for loop" and the function rand(1) to create a vector x(n) with 500 elements. Then compute the average value of the elements in x (b) Use another "for loop" and rand(1) to create a vector y(n) of 500 random numbers between the numbers -2 and +2. 2. Leap Year Program (practice your IF statements!) Write a code to determine if a year is considered a leap year or not? Display to the screen if the year is a leap year or not. Use num2str() and display() or fprintf In the Gregorian calendar three criteria must be taken into account to identify leap years: The year is evenly divisible by 4 (Exceptions 1700, 1800, and 1900); If the year can be evenly divided by 100, it is NOT a leap year, unless; The year is also evenly divisible by 400. Then it is a leap year
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
