MATLAB script runs slowly: Solving System of Equations
<p><strong>EDIT:</strong> I used the profiler as suggested, and it looks like Matlab was spending a significant amount of time dealing with symbols and solving the system of equations. So, I will change my question slightly: is there a faster way to implement this system of equations, perhaps one that does not involve declaring symbols? </p>

<pre><code>function [As_rad, Ae_rad] = pos_to_angle(x_pos, y_pos)
    % Converts given x and y coordinates into angles (using link lengths)

    Ls = 0.4064;   % in meters
    Le = 0.51435;  % in meters
    x_offset = 0.0;
    y_offset = -0.65;   % from computer running the robot

    syms angle_s angle_e

    x = x_pos + x_offset;       % Account for offset of origins
    y = y_pos + y_offset;       % between motor and workspace

    eqn1 = x == Ls*cos(angle_s) + Le*cos(angle_e);  % Actual conversion
    eqn2 = y == Ls*sin(angle_s) + Le*sin(angle_e);
    sol1 = solve([eqn1, eqn2], [angle_s, angle_e]);
    As_rad_mat = sol1.angle_s;
    Ae_rad_mat = sol1.angle_e;

    if As_rad_mat(1) &gt; Ae_rad_mat(1);
        As_rad = As_rad_mat(1);
        Ae_rad = Ae_rad_mat(1);
    else
        As_rad = As_rad_mat(2);
        Ae_rad = Ae_rad_mat(2);
    end
end
</code></pre>

<p>To be more specific, it looked like a function mupadmex (which I believe is associated with symbols) took up about 80% of the computing time. The above is just an example of how I solved systems of equations throughout the script.</p>