Solution.
The Jacobian matrix is
\begin{equation*}
J = \begin{pmatrix}
2x_1e^{3x_2} \amp 3x_1^2e^{3x_2} \\
x_2-\cos(x_1+x_2^2) \amp x_1-2x_2\cos(x_1+x_2^2)
\end{pmatrix}
\end{equation*}
As a Matlab function, it can be written as follows.
J = @(x) [2*x(1)*exp(3*x(2)), 3*x(1)^2*exp(3*x(2));
x(2) - cos(x(1) + x(2)^2), x(1) - 2*x(2)*cos(x(1) + x(2)^2)];
The linebreak between matrix rows is optional but improves readability.
