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
Model the three degree of freedom system shown in Figure Q5 and solve for the displacements of the three masses due to a force of 10 N applied to the bottom mass at a frequency of

Statement of Problem I need to realise vector-array multiplication in Simulink. This has been realised in Matlab but because the process yielding the received signal is in Simu

An individual with $10,000 to invest has identi?ed three mutual funds as attractive opportunities. Over the last ?ve years, dividend payments (in cents per dollar invested) have be

String Manipulation: The string in MATLAB software consists of any number of characters and is contained in the single quotes. Actually, strings are considered as vectors in w

An environmental consulting firm is conducting a site investigation on an abandoned industrial site that is 200 m by 150 m in size (Fig. 1). A number of piezometers were installed

what are the steps we need to write in the script to get themedian for X values

Create a GUI that has A button to bring up a dialog to select a text file and read it in. Plot the x,y values on the GUI Have text entry values, one for each parameter, in which

This can be done from the command line or from a makefile. You require a script (filename.m). Just type at the command line, or contain in the makefile: matlab

Variable number of output arguments: The variable number of output arguments can also be identified. For illustration, the one input argument is passed to the below function t

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