how to get the outputs of an expression with a random variable input
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
segun
am 21 Apr. 2014
Bearbeitet: segun
am 21 Apr. 2014
Hi,
I need hints on how to use random variable change as one of the input in an expression and get the (30)different outputs displayed for each of the random variable change. An example is shown below:
f=100;
a = 90
b = 100
z= a + (b-a)*rand(1:30)
c = 2; d = 2;
Y = f*b*c*z;
disp(Y); % display 30 Y outputs for all the random variable changes
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 21 Apr. 2014
If you want a vector of 30 random numbers, you would use rand(1,30)
2 Kommentare
Walter Roberson
am 21 Apr. 2014
The disp(Y) will do that. Your f, b, and c are scalars and your z is a vector (once you fix the rand() call), so your Y = f*b*c*z will be a vector, and disp(Y) will display that vector of 30 values.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!