the histgram of G is showing a straght line in this code

1 view (last 30 days)
R10=2e3
dR=0.01
DeltaR=(rand(1000,1)-0.5)*2
R1=R10*(1+DeltaR*dR)
figure; hist(R1,20)
R20=18e3
dR=0.01
R2=R20*(1+DeltaR*dR)
figure; hist(R2,20)
G=1+R2./R1
figure; hist(G,200)
  1 Comment
Walter Roberson
Walter Roberson on 19 Apr 2021
format long g
R10=2e3
R10 =
2000
dR=0.01
dR =
0.01
DeltaR=(rand(1000,1)-0.5)*2;
DeltaR(1:10)
ans = 10×1
0.456850403382957 0.829686060953362 -0.89642340724095 0.466597228156508 0.977663054020667 -0.87630487096742 0.888444975804023 -0.35566284936498 0.70593257404108 0.123539848371262
R1=R10*(1+DeltaR*dR);
R1(1:10)
ans = 10×1
2009.13700806766 2016.59372121907 1982.07153185518 2009.33194456313 2019.55326108041 1982.47390258065 2017.76889951608 1992.8867430127 2014.11865148082 2002.47079696743
figure; hist(R1,20)
R20=18e3
R20 =
18000
dR=0.01
dR =
0.01
R2=R20*(1+DeltaR*dR);
R2(1:10)
ans = 10×1
18082.2330726089 18149.3434909716 17838.6437866966 18083.9875010682 18175.9793497237 17842.2651232259 18159.9200956447 17935.9806871143 18127.0678633274 18022.2371727068
figure; hist(R2,20)
G=1+R2./R1
G = 1000×1
10 10 10 10 10 10 10 10 10 10
figure; hist(G,200)

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 19 Apr 2021
DeltaR=(rand(1000,1)-0.5)*2
R1=R10*(1+DeltaR*dR)
So R1 is a constant times (1+DeltaR*dR)
R2=R20*(1+DeltaR*dR);
so R2 is a constant times (1+DeltaR*dR)
G=1+R2./R1
The (1+DeltaR*dR) are present in both R2 and R1, so the R2./R1 is going to be R20/R10 which is a constant. So G is going to be 1 + the ratio of the two constants, and so is going to be a constant.
  2 Comments
ZHuoyan Liu
ZHuoyan Liu on 20 Apr 2021
Thanks!
that means that if i create two seperate (1+DeltaR*dR) for R1 and R2 the result should be showing the randomised output right?
Walter Roberson
Walter Roberson on 20 Apr 2021
If you have two difference random DeltaR for R1 and R2, then Yes, the result will not be the same for all of the entries.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!