Illustrations of calling the rand function, MATLAB Programming

Illustrations of calling the rand function:

The function ‘rand’ can be used to produce random real numbers; calling it produces one random real number in the range from 0 to 1. There is no argument passed to the rand function. Here are two illustrations of calling the rand function:

>> rand

ans =

0.9501

>> rand

ans =

0.2311

The seed for the rand function will always be similar each time the MATLAB is started, unless the state is changed, for illustration shown:

 

rand(‘state’,sum(100*clock))

 

This uses the present date and time which are returned from the built-in clock function to set the seed. Note: this is completed only once in any given MATLAB session to set the seed; the rand function can be used as shown earlier in any number of times to produce random numbers.

As rand returns a real number in the range from 0 to 1, multiplying the answer by an integer N would return the random real number in a range from 0 to N. For illustration, multiplying by 10 returns a real in the range from 0 to 10, therefore this expression

rand*10

would return the outcome in the range from 0 to 10.

Posted Date: 10/18/2012 4:04:17 AM | Location : United States







Related Discussions:- Illustrations of calling the rand function, Assignment Help, Ask Question on Illustrations of calling the rand function, Get Answer, Expert's Help, Illustrations of calling the rand function Discussions

Write discussion on Illustrations of calling the rand function
Your posts are moderated
Related Questions
As shown in Figure 1, Ecosystem carbon (C) cycles in a tropical forest can be modeled using three "compartments":  aboveground (AG), belowground (BG), and soil organic matters (SOM

how to write the national log (ln(x)) in matlap ?

User-Defined Functions which return a Single Value: We have seen the use of many functions in the MATLAB. We have used many built-in functions like fix, sin, abs, double, and

Expressions: The Expressions can be formed using values, variables which have already been formed, operators, parentheses, and built-in functions. For numbers, these can invol

It is desired to determine the DFT of the analogue signal x (t) = 25 cos(10 Πt)cos(400Πt). (a) Find the Nyquist rate of the signal.   (b) What is the record (signal) length i

I am doing project "Recognizing people in video based on their body" the system will use MATLAB to detect people based on thier body and then recognize them from their clothes "us

Reading from a File: A file has been once created; it can be read into a matrix variable. When the file is a data file, the load function will read from the file filename.ext


Illustration of Output statements: For illustration, >> disp('Hello') Hello >> disp(4^3)   64 The formatted output can be printed to the screen by using the fpr

a. Run the simulation you developed for 10 one-day periods. Provide a table of the Peak Power required for each day. b. Based on this information, and the fact additional capaci