Uniformly distributed random variables
이전 댓글 표시
Iam stuck in a part of the following question-
Plot the distribution of two resistors in a parallel connection assuming that they each have measured values, which vary uniformly about their nominal values by ±5%
I have approached this problem in the following way -
x = zeros(10000,1) ;
R1 = rand(1,1) ;
R2 = rand(1,1) ;
for i = 1:10000
x(i,1) = (R1*R2)/(R1+R2) ;
end
histogram(x,'normalization','pdf')
RIght now I dont have the idea about how to adjust the nominal values in the rand function . Please help :)
댓글 수: 1
the cyclist
2021년 4월 5일
I edited your code using the CODE button in the toolbar, and run it, show in your plot.
채택된 답변
추가 답변 (2개)
David Hill
2021년 4월 5일
nomR1=1000;
nomR2=2000;
R1=nomR1*(.05*(2*rand(1,1e4)-1)+1);
R2=nomR2*(.05*(2*rand(1,1e4)-1)+1);
x=(R1.*R2)./(R1+R2);
댓글 수: 2
the cyclist
2021년 4월 5일
@Anand Kumar, my advice to you would be to try to solve your homework yourself with the hints I gave, before blindly copying this solution. That's the way to learn.
Anand Kumar
2021년 4월 5일
The main reason your output looks like this is that you are only generating ONE random value for each resistor -- and then recalculating x over and over again, with those values.
So, you need to change your code so that you generate a new random value for each value of x. (Check out the documentation on rand to see how to generate many values at once.)
You can generate a uniform random value with mean m and width w by doing
m = 37;
w = 2;
R1 = m + w*(rand(1,1) - 0.5)
카테고리
도움말 센터 및 File Exchange에서 Uniform Distribution (Continuous)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

