Integration with negative support

Hi, I would like to integrate something like this
z=@(x) x<0;
integral(exppdf(z,10),-0.5, 0.5);
Any help will be useful. Thanks

답변 (1개)

Rik
Rik 2017년 2월 21일

0 개 추천

You are aware that you are not creating a bound, but a function that says that z is either 1 or 0?
And that there is a vital difference between integrate() and integral()?
Anyway, I copied out the function that exppdf calculates from its help, which resulted in the code below:
mu=10;
z=@(x) (1/mu)*exp(-x/mu);
integral(z,-0.5, 0.5);

댓글 수: 4

Nikolas
Nikolas 2017년 2월 21일
Thanks for your answer. Is it possible to take only x<0?
Sure, but not if you are integrating for x from -0.5 to 0.5
integral(z,-0.5, 0);
Thank you once again for your post. What about if i use exppdf, which is a built in function in MATLAB which returns 0 if x<0, can I use it? Then I think if you take the integral
integral(z,0,0.5)
should return zero. I want to use this function.
Why do you want to use this function? And if you use exppdf as an input, the integral for 0 to 0.5 should not be 0. There is another thing that may be what you mean:
z2=@(x) exppdf(-x,mu);%turn positive x into negative and vice versa
This will return 0 for integral(z2,0,0.5)

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

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2017년 2월 21일

댓글:

Rik
2017년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by