Plotting a line with negative slope in Mathematica

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 4K views
yaang
Messages
22
Reaction score
0
I want to plot a line in mathematica with a negative slope by setting it's starting point, length, and slope but i couldn't figure out how to do it.

example: A line "AB"
has a starting point (40,0)
has a length 10
has an angle 127 degrees between x axisIn MATLAB i can do this with
%%
k = 0:0.1:10;
x=40+k*cosd(127);
y=0+k*sind(127);
plot(x,y)
%%
Result:http://i53.tinypic.com/2lb18x.pngHow can i do this with mathematica ? Can anyone help ? (I don't want to draw it from it's end point to beginning point )
 
Last edited:
Physics news on Phys.org
There are, of course, many ways to achieve this in Mathematica, but the exact analogue of your code would be:

k = Range[0,10,0.1];
x=40+k Cos[127 Degree];
y=0+k Sin[127 Degree];
ListPlot[Transpose[{x,y}],Joined->True]

You get the same result from

ParametricPlot[{40 + t Cos[127 Degree], t Sin[127 Degree]}, {t, 0, 10}]
 
Thanks for the detailed answer, first way you showed looks especially interesting.