your solutions is pretty clear. I presume, that you have X,Y cords. Once, you have them, its a cakewalk. Slope of a line is given by: m=(y2-y1)/(x2-x1) i.e. dy/dx, where point1 cordinates = (x1,y1) & point2 cordinates = (x2,y2).
Now in order to get the angle, just do an arctangent of the slope. Angle = arctan(m), where m is slope from above.
Just implement these mathematical formulas in MATLAB and its done.
Hope it helps. Regards, Pratik