No BSD License  

Highlights from
PathRep

from PathRep by Tim Farajian
Generates the parametric representation of a path on the complex plane.

PathRep(zi, zf, f)
function z = PathRep(zi, zf, f)
%PATHREP  Generates the parametric representation of a path on the complex
%plane using the real parameter t over the range 0<=t<=1.
%
%   z = PathRep(zi, zf, f) where
%
%    zi is the initial point of the path.
%    zf is the final point of the path.
%    f is a string containing the equation of the path given either
%      as y(x) or x(y).  If this input is empty or omitted, the path
%      is assumed to be a straight line.
%
%    z is the parametric representation as a function of t.
%
%    Example:  z = PathRep(-1-i, 1+i, 'x^2 + x - 1') returns z = -1+2*t+sqrt(-1)*((-1+2*t)^2-2+2*t)

syms t real %Decalare real sym variable
if nargin < 3 | isempty(f),
    z = zi + (zf - zi)*t; %Default straight line path
    return
else
    fs = [' ' findsym(sym(f)) ','];
    if strfind(fs, ' x,') & strfind(fs, ' y,')
        error('f can only be a function of either x or y, not both')
    elseif strfind(fs, ' x,')
        yt1 = subs(f, 'x', real(zi));
        yt2 = subs(f, 'x', real(zf));
        if imag(zi)~=yt1 | imag(zf)~=yt2
            error('One or both of the endpoints are not on the given path y(x)')
        end
        x = real(zi + t*(zf - zi)); %Generate x(t)
        y = subs(f, 'x', x); %Generate y(t)
        z = simple(x + i*y); %Generate z(t) 
    elseif strfind(fs,' y,')
        xt1 = subs(f, 'y', imag(zi));
        xt2 = subs(f, 'y', imag(zf));
        if real(zi)~=xt1 | real(zf)~=xt2
            error('One or both of the endpoints are not on the given path x(y)')
        end
        y = imag(zi + t*(zf - zi)); %Generate x(t)
        x = subs(f, 'y', y); %Generate y(t)
        z = simple(x + i*y); %Generate z(t) 
    else
        error('f must be a function of either x or y.')
    end
end

Contact us at files@mathworks.com