Yes, it is possible to use a Custom Equation in CFTOOL defined from a MATLAB file. Here is an example. Start by creating a file like this:
function y = my_curve( x, a, b, c )
y = zeros( size( x ) );
isLeft = x < 0.5;
y(isLeft) = a + b*x(isLeft);
y(~isLeft) = a + c*x(~isLeft);
The key things about this file are
- it has an input for the x-data, x
- it has one input for each coefficient, a, b and c.
- the y-data, y, that is returned is the same size as x
- it will work when the x-data, x, is a vector.
In CFTOOL you can then follow the usual steps to create a Custom Equation. Choose a General rather than Linear equation. For the equation, enter my_curve( x, a, b, c ).
If you need a surface, then you can do all the same stuff in SFTOOL, just add an input argument for y-data and make sure that your function works when the x- and y-data are vectors.