how to get the outputs of an expression with a random variable input

조회 수: 1 (최근 30일)
segun
segun 2014년 4월 21일
편집: segun 2014년 4월 21일
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

채택된 답변

Walter Roberson
Walter Roberson 2014년 4월 21일
If you want a vector of 30 random numbers, you would use rand(1,30)
  댓글 수: 2
segun
segun 2014년 4월 21일
I mean how do I make the above expression display 30 different answers from the input of 30 random numbers as shown in the matlab codes posted
Walter Roberson
Walter Roberson 2014년 4월 21일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by