how to remove error"Conversion to logical from sym is not possible."?
古いコメントを表示
i make a fuction that take anynomous fuction as input with value ,
the fuction perform leftsum and definate integral if ' tol' value that is varialble take value from input lies between the value of left sum and integral the it generate the output 1 otherwise 0
i have made that code
function output=myleftcheck(f,a,b,n,tol)
syms x
dx=(b-a)/n;
% initialize r to f(a) (the left-end point of the first sub-interval
% [a,a+dx])
r=0;
% need only consider the n-1 remaining sub-intervals
for k=0:n-1
c=a+k*dx;
r=r+f(c);
end
t=dx*r;
o=int(f(x),a,b)
p=vpa(o)
if p < tol >t
output=1
else
output=0
end
the following error is coming,how i should debugg the error
>> myleftcheck(@(x) sin(x),0,3.14,10,0.1)
o =
1 - cos(157/50)
p =
1.999998731727539545285114306345
Conversion to logical from sym is not possible.
Error in myleftcheck (line 15)
if p<= tol >=t || t<=tol>=p
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Assumptions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!