필터 지우기
필터 지우기

Plotting a line of desired length starting from a particular point with slope given.

조회 수: 17 (최근 30일)
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??
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
Praveen Patnaik
Praveen Patnaik 2020년 11월 17일
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+')

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2020년 11월 17일
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')

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by