Hello Abeljohn,
I understand from your query that you want to know why the graph does not display the trajectory correctly.
From your code and the comments, I assume that you want the trajectory to be directed from the XZ plane, with the Y axis denoting the height. The reason that you get a sideways rotated trajectory is that in your graph is the orientation of the planes. The base plane in your graph is XY plane.
To obtain a graph where the projectile is launched vertically upwards from the plane, you can make the following change to your code:
x = v0 * t * cos(elevation) * cos(azimuth);
y = v0 * t * sin(elevation) - 0.5 * g * t.^2;
z = v0 * t * cos(elevation) * sin(azimuth);
plot3(x, z, y, 'LineWidth', 2);
title('3D Artillery Simulation');
As you can see, the trajectory is not rotated sideways now.
You can refer to the below documentation of the 'plot3' function for more information:
Hope this helps.