How can I fix error in fzero (line 241)
조회 수: 1 (최근 30일)
이전 댓글 표시
When I use the following fzero function in Matlab R2012a:
for jj=1:358;
mat=cv_o2{jj};
pr=CC_m{jj};
x = [-5 100];
fun = @(x)mat-(std(power(pr,x),1,3)./mean(power(pr,x),3))
b=fzero(fun,x);
BB{jj}=b;
end
end
I get the following error message:
Operands to the || and && operators must be convertible to logical scalar values.
Error in fzero (line 241)
if any(~isfinite([fa fb])) || any(~isreal([fa fb]))
I do not understand what the matter is. Could someone write me how can I fix this error?
댓글 수: 0
답변 (1개)
Titus Edelhofer
2015년 9월 3일
Hi,
fzero works for scalar valued functions. Looking at your function I guess it's not scalar valued (i.e., if you call your function fun for one value, the value should not be a vector/matrix but a scalar ("number").
Titus
댓글 수: 7
Torsten
2015년 9월 4일
pr(i,j) is a scalar. Thus taking nanstd(pr(i,j)^x) gives Inf since you divide by 0.
Best wishes
Torsten.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!