Conditional in for-loop
이전 댓글 표시
x = 0:0.1:10;
y = exppdf(x,2);
Plot the pdf.
figure;
plot(x,y)
what if I have P (0 <x< 10) , how should I write it in matlab?
Thanks
댓글 수: 3
Bob Thompson
2021년 2월 8일
편집: Bob Thompson
2021년 2월 8일
What is P?
Generally logic with multiple conditions uses & (&&) and | (||) for 'and' and 'or' statements. So to define 0 < x < 10 you would write something like the following:
P = x > 0 & x < 10;
noname
2021년 2월 8일
Bob Thompson
2021년 2월 8일
Ah, probability isn't really my strong suit, as a concept.
From what little I do understand, wouldn't the probability of any individual value of x (not sure if this is what condition you're actually looking at) is within the range of 0 < x < 10 just be the percentage of x values within that range? If so, you can calculate that like the following:
P = sum(x>0&x<10)/length(x);
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Uniform Distribution (Continuous)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!