[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Conditions in Function Definitions
From: |
stein |
Subject: |
Conditions in Function Definitions |
Date: |
Tue, 30 Jun 1998 00:16:38 +0200 (MET DST) |
Hello,
this is a question relating function definitions and
their respective solvers (fsolve, dassl ...).
Is it possible to define a (linear, non-linear, 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Conditions in Function Definitions,
stein <=