Plotting a line of desired length starting from a particular point with slope given.
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Any hints or suggestion will do.
I want to plot a line of desired length without that intersecting any axis.
Slope , length and starting point of line is given but no C (intercept is given). How do I plot it??
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/416438/image.png)
I was initially thinking of plotting a line of given length about orign and then shifiting it to different location.
please give your valuable feedback
For example we can plot an arc using parametric form about (0,0) and later shift it can this be done to a line???
r = 10; % arc length
aa = 60*pi/180; % arc angle
ap = 0*pi/180; % arc position angle
t1 = linspace(0,aa)-aa/2+ap;
[x1,y1] = pol2cart(t1,r); % arc data
% shifting arc to (10,20)
x1=x1+10
y1=y1+20
plot (x1,y1)
1 Commento
Praveen Patnaik
il 17 Nov 2020
clc
clear
r = linspace(0,5); % line segment lenth max is 5 and min is 0
theta = 60*pi/180; % angle of inclination
% starting point
x0=2;
y0=4.4641;
x1=x0+ r* cos(theta);
y1=y0+r * sin(theta);
% for highlighting point
ind= [25 75];
x1_h=x1(ind);
y1_h=y1(ind);
plot (x1,y1,x1_h,y1_h,'r+')
Risposte (1)
KSSV
il 17 Nov 2020
P0 = rand(1,2) ; % initial point
m = 1. ; % slope
% Equation of line y-y1 = m*(x-x1)
x1 = 1. ; % some value
y1 = P0(1)+m*(x1-P0(1)) ;
P1 = [x1 y1] ; % second point
%
v = P1-P0 ;
u = v/norm(v) ;
%
d = 6 ; % get a point at this distance
P = P0+d*u ;
% Check
s = sqrt((P0(1)-P(1))^2+(P0(2)-P(2))^2) ;
[s d]
% plot
plot([P0(1) P1(1)],[P0(2) P1(2)])
hold on
plot(P(1),P(2),'*r')
0 Commenti
Vedere anche
Categorie
Scopri di più su Scatter Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!