function ts=title_string_left(n,coeff)
% A function for the MATLAB program curves of unity that
% formats the output for the titles of each curves of unity
% graph and returns them in a nx31 matrix
% NB: 37 characters is the max in any one string
% Create title string,ts, for proper labeling
num_terms=length(coeff);
max_char=37;                    % The maximum # of char
if max(coeff)>=10               % in any one string
    max_char=max_char+1;        % Number of columns in ts must
end                             % be constant for all rows of ts
if max(coeff)>=100
    max_char=max_char+1;
end  
if n>10
    max_char=max_char+1;
end

% Set first term
tmp=['cos{^' num2str(n) '}(\theta)' ];  
for ctr=1:(max_char-length(tmp))
    tmp=[' ' tmp];          % Set proper length
end
ts(1,:)=tmp;                % first string of ts with correct length

% Left half of equations on plot titles
for i=1:(num_terms-1)             
    k=i+1;                  % Set index for reference of other variables
    tmp=[''];               % Clear tmp variable
    if mod(i,2)==0          % Even terms: j^i = 1 or -1
        if j^i==-1
            tmp=['-'];      % Add '-' sign
        end
    else                    % Odd terms: j^i = j or -j
        if imag(j^i)==-1
            tmp=['-j*'];
        else
            tmp=['j*'];
        end
    end
    tmp=[tmp num2str(coeff(k))];
                            % add proper poly_coeff
                            
    if (n-i)~=1             % add proper power of cos(x)
        tmp=[tmp '*cos{^' num2str(n-i) '}(\theta)'];  
    else
        tmp=[tmp '*cos(\theta)'];
    end
    
    if i~=1                 % add proper power of sin(x)
        tmp=[tmp '*sin{^' num2str(i) '}(\theta)'];  
    else
        tmp=[tmp '*sin(\theta)'];
    end

    if length(tmp)<max_char
                            % Set proper length
        for ctr=1:(max_char-length(tmp))            
            tmp=[' ' tmp];
        end
    end
    ts(k,:)=tmp;
end

% Set last term
i=i+1;
if mod(n,2)==0              % Even terms: j^i = +1 or -1
        if j^n==-1
            tmp=['-'];      % Add '-' sign
        else
            tmp=['+'];      % Add '+' sign
        end
    else                    % Odd terms: j^i = j or -j
        if imag(j^n)==-1
            tmp=['-j*'];
        else
            tmp=['j*'];
        end
    end
tmp=[tmp 'sin{^' num2str(n) '}(\theta)'];
                            % Set proper length
for ctr=1:(max_char-length(tmp))                
    tmp=[' ' tmp];
end
ts(i,:)=tmp;