
Hello,
this is a question relating function definitions and
their respective solvers (fsolve, dassl ...).
Is it possible to define a (linear, nonlinear, or DAE) function
containing a condition?
The following example is syntactically wrong:
function y = f(x)
y(1) = if (x(1)>1)
2*x;
else
4*x;
endif;
y(2) = x(1)+x(2);
endfunction
In this example, the assignment to y(1) is executed only one time, in the
first evaluation, thus not reflecting the desired behavior:
function y = f(x)
if (x(1)>1)
y(1) = 2*x;
else
y(1) = 4*x;
endif
y(2) = x(1)+x(2);
endfunction
Have a nice day,
Benno
