
Error using integral (line 85) A and B must be floating-point scalars.
조회 수: 3 (최근 30일)
이전 댓글 표시
My code is:
b=10;a=3;q=0.1;
scdf = @(x) (1-(b./(x+b)).^a)./(1-(b./(10+b)).^a);
integral(@(x) (1+q).*(1-scdf(x)).^0.5,0,10);
psi = @(p) integral(@(x) (1-scdf(x)).^0.5,0,10)-p./(1+q)-integral(@(x) (1-scdf(x)).^0.5,0,3-p);
p=0:0.001:3;
plot(p,psi(p))
The error is:
Error using integral (line 85)
A and B must be floating-point scalars.
Error in ambiguity>@(p)integral(@(x)(1-scdf(x)).^0.5,0,10)-p./(1+q)-integral(@(x)(1-scdf(x)).^0.5,0,3-p)
Error in ambiguity (line 9)
plot(p,psi(p))
Any help is very appreciated! Thanks in advance.
댓글 수: 0
채택된 답변
Ameer Hamza
2020년 5월 11일
integral() function cannot accept a vector for its limits. So you cannot pass p as a vector. You will need to pass each value of p, one by one. For this, you can use arrayfun(). Try this code
b=10;a=3;q=0.1;
scdf = @(x) (1-(b./(x+b)).^a)./(1-(b./(10+b)).^a);
psi_ = @(p) integral(@(x) (1-scdf(x)).^0.5,0,10)-p./(1+q)-integral(@(x) (1-scdf(x)).^0.5,0,3-p);
psi = @(p) arrayfun(psi_, p);
p=0:0.001:3;
plot(p,psi(p))

추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Continuous에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!