MATLAB: How to plot a curve using angles

curve fittinginterpolationMATLAB

I want to plot the 2D curve that passes through a number of points for which I only have the angle (inclination of the curve with respect to the vertical) and the length of the line between each two points. The form of the line should be a spline in order to get a smooth curve of the coordinates y with respect to the coordinates x. Here's an example of the data I have:
s = linspace[0,1000,100]; % Each entry of this vector represents the location of the respctive point on the curve
Inc = linspace[0,1.5708,100] % This is only an example that shuould describe a quadrant, whereas the actual angles that I have are not as perfect
My goal is to get the actual values of x and y for any given point along the curve. Suppose the curve starts from the origin [0,0].
The result obtained from the above data should be your usual quadrant, or something close.
P.S. I'm not all that familiar with MATLAB so please don't leave out any details.
Thanks in advance.

Best Answer

Try cumsum
ds = rand(1,10); % length of each segment
a = rand(1,10)*90; % angle of each segment
dx = sind(a).*ds; % projection of segment on X axis
dy = cosd(a).*ds; % projection of segment on Y axis
x = [0 cumsum(dx)];
y = [0 cumsum(dy)];
plot(x,y)
See more about cumsum
>> cumsum([1 0 2 1])
ans =
1 1 3 4