Paul
2008-05-22 16:45:04 UTC
I have defined the following function m-file:
function out=fxn1(x)
if x>=0 && x<= 100
out=x;
end
end
If I call it using a handle in quad, as follows:
quad(@fxn1,0,10)
I get the error message:
??? Operands to the || and && operators must be convertible
to logical scalar values.
The example above is a trivial function, but I have some
very complex functions, which take different algebraic
forms for different ranges of their arguments. Defining
them as function m-files, using relational operators in the
m-files, seems convenient. Can anyone suggest how I might
be able to call these functions in quad or other similar
matlab functions, without getting this error message?
function out=fxn1(x)
if x>=0 && x<= 100
out=x;
end
end
If I call it using a handle in quad, as follows:
quad(@fxn1,0,10)
I get the error message:
??? Operands to the || and && operators must be convertible
to logical scalar values.
The example above is a trivial function, but I have some
very complex functions, which take different algebraic
forms for different ranges of their arguments. Defining
them as function m-files, using relational operators in the
m-files, seems convenient. Can anyone suggest how I might
be able to call these functions in quad or other similar
matlab functions, without getting this error message?