Question

The rand() function generates a random real number between 0 and 1, but what if we...

The rand() function generates a random real number between 0 and 1, but what if we want real numbers in a different range? Use the rand function to generate a 4x5 matrix with random real numbers between 5 and 10. Store your result in the variable "mat".

0 0
Add a comment Improve this question Transcribed image text
Answer #1
% Code
mat = (10-5)*rand(4,5)+5

Output:

octave: 1> mat = (10-5) *rand (4,5) +5 mat = 7.1797 6.3239 7.3478 9.4018 9.7492 5.7504 6.5630 9.9115 6.1135 9.3635 8.8120 6.5

Note : Please comment below if you have any doubts, upvote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
The rand() function generates a random real number between 0 and 1, but what if we...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (b) What is the probability of generating a random number between 0.35 and 0.65? (c) What...

    (b) What is the probability of generating a random number between 0.35 and 0.65? (c) What is the probability of generating a random number with a value less than or equal to 0.20? (d) What is the probability of generating a random number with a value greater than 0.60? (e) Generate 50 random numbers by entering =RAND() into 50 cells of an Excel worksheet. This answer has not been graded yet. (f) Compute the mean and standard deviation for the...

  • A coder programmed a random number generator, which generates a random number between 0 and 1...

    A coder programmed a random number generator, which generates a random number between 0 and 1 when the user presses the "random" button. Numbers generated follow a uniform distribution. 12- What is the probability the next time the button is pressed the code will generate a number less than .23? 13- What is the probability the next time the button is pressed the code will generate a number between .23 and .35? 14- What is the probability the next time...

  • 4. Write a program that generates one hundred random integers between 0 and 9 and displays...

    4. Write a program that generates one hundred random integers between 0 and 9 and displays the count for each number. (Hint: Use rand()%10 to generate a random integer between 0 and 9. Use an array of ten integers, say counts, to store the counts for the number of 0’s, 1’s,…..,9’s.) this program kinda works but i cant figure out why its making more than 100 random numbers ls) [*] test2.cpp test3.cpp #include<stdio.h> #include<stdlib.h> int main() 4 { int a[14],is...

  • Many random number generators allow users to specify the range of the random numbers to be...

    Many random number generators allow users to specify the range of the random numbers to be produced. Suppose that you specify that the range is to be all numbers between 0 and 5. Call the random number generated Y. Then the density curve of the random variable Y has constant height between 0 and 5, and height 0 elsewhere. 1. Use Excel to generate 100 random values from the above distribution. Construct a histogram for generated values [ Note: use...

  • Write a C++ program that generates twenty five random integers between 0 and 24 and display the sum of even integers.

    (C++)Write a program that generates twenty five random integers between 0 and 24 and display the sum of even integers. (Hint: Use rand()%25 to generate a random integer between 0 and 24. Use an array of 25 integers, say num , to store the random integers generated between 0 and 24.)

  • The random-number generator on calculators randomly generates a number between 0 and 1. The random variable...

    The random-number generator on calculators randomly generates a number between 0 and 1. The random variable X, the number generated, follows a uniform probability distribution. (a) Identify the graph of the uniform density function. (b) What is the probability of generating a number between 0.85 and 0.96? (c) What is the probability of generating a number greater than 0.88? (a) Choose the correct graph of the uniform density function below. ОА. OB. OC. A Density Density A Density ON ON...

  • Help please! Program in C Problem-4 Write a function that receives an unsigned number and generates...

    Help please! Program in C Problem-4 Write a function that receives an unsigned number and generates and returns a new number that may or may not have an error in it. An error on a random bit must be introduced randomly. Use the rand function to generate 0 or 1 to see if the error needs to be generated and use a rand function in the range of 1 to 32 to see on which bit positon the error needs...

  • Write a C++ program that generates a random number from 0 to 9. It will then...

    Write a C++ program that generates a random number from 0 to 9. It will then prompt the user to guess the random number it generated. Your program stops if the user guesses the right number. (Use the cout function to display the random number the computer generates so that you can determine if your code actually works). SAMPLE OUTPUT Random number = 8 Guess a number in the range [0,9]: 1 Too low Guess a number in the range...

  • most computer languages include a function that can be used to Generate random numbers in Excel...

    most computer languages include a function that can be used to Generate random numbers in Excel the Rand function can be used to Generate random numbers between 0 and 1 if we let X denote a random number General using R and then X is a continuous random variable with the following probability density function

  • Most computer languages include a function that can be used to generate random numbers. In Excel,...

    Most computer languages include a function that can be used to generate random numbers. In Excel, the RAND function can be used to generate random numbers between 0 and 1. If we let x denote a random number generated using RAND, then x is a continuous random variable with the following probability density function. for 0 sxs 1 elsewhere (a) Graph the probability density function. f(x) f(x) EEEEEEEEEEEEE Endas tiers - 3 - Terce BOORTE E segments Egertice Tesegent o...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT